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?
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
}
}
You can only run tsc to compile your js file.
if u run tsc file.js, it will throw an error.
Because if you run tsc, it will find the nearest config file, but if you run tsc file.js, it will run depending on the default file(allowJs:false, ignore tsconfig.json).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With