TS6504

error TS6504: File ‘mycode.js‘ is a JavaScript file. Did you mean to enable the ‘allowJs‘ option?

Broken Code ❌

1
tsc mycode.js

Fixed Code ✔️

You have to enable the “allowJS” flag in your “tsconfig.json” file:

tsconfig.json
1
2
3
4
5
{
"compilerOptions": {
"allowJs": true
}
}

Alternatively, you can enable it through the TypeScript Compiler CLI:

1
tsc mycode.js --allowJs