Aaron Beall
Aaron Beall

Reputation: 52183

TS import from ES6 file

I'm using Webpack in an ES6 project. I am attempting to enable TypeScript without converting all files to .ts. However TS does not recognize any of my ES6 modules. Example:

I have a .js file which uses ES6 module syntax:

export default "foo";

In a .ts file I want to import "foo":

import foo from "./foo";

However TypeScript tells me that it Cannot find module "./foo".

Is there any way to make TS understand that these modules exist without writing d.ts files for all of them (not really possible) or convert everything to .ts?

Upvotes: 3

Views: 1109

Answers (1)

basarat
basarat

Reputation: 276235

I have a .js file which uses ES6 module syntax:

Add allowJs to your tsconfig.json 🌹

Upvotes: 7

Related Questions