I am trying to use in my Angular 5 application a .js file which is avaible just in JavaScript language, so I can't find an alternative in TypeScript.
The problem is that I have added the "allowJs": true
in my tsconfig.json, but the error is still active. My tsconfig.json is:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"allowJs": true,
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
The error is:
'<path>/file.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.
Whats wrong?
.ts
? Keep in mind that any validjs
file is a validts
file as well, so changing the extension shouldn't cause any trouble (other than the usual type warnings perhaps) and should get rid of the error. – Tungstiteprisma generate client
it is in my project but not on git, it is necessary since I use yarn4 that it is within the scope that I can import. I also have the same issue when using allowJs: true it can be imported, but checkJs: false does not work and I don't know what to do because I can't use annotation in generated file. It suck – Brand