Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I compile a .js file with the TypeScript compiler without renaming it to a .ts file?

Tags:

typescript

I would like to get an error and warning list from the TypeScript compiler when it is run against my .js files. i.e. not ready to convert this project's .js files to .ts files but still want to get some of the inferred typing from the tsc compiler to see what warnings and errors it would generate against a project's .js files.

Is there a way to run the tsc compiler against a .js file and tell it to treat the .js file as input and not to generate an output file but instead to generate just the errors and warnings?

like image 251
Guy Avatar asked Jan 28 '26 12:01

Guy


1 Answers

I know this an old question, but for new readers, from the command line you can do

tsc --AllowJs --checkJs 

Or set those to true in your tsconfig.json

Source: https://www.typescriptlang.org/docs/handbook/compiler-options.html

like image 192
Arman Avatar answered Jan 31 '26 02:01

Arman