2

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?

3 Answers 3

8

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

5

It's such a common user error (one letter off) with such annoying consequences (pages full of errors) that the compiler won't do it. You could remove the check from the source code pretty easily, though -- just change the implementation of isTSFile

1
  • 1
    @BASarat you forgot to hit the +1 :)
    – Fenton
    Jul 9, 2013 at 10:47
0

Thanks to @Ryan's comment. I've done this a few times and wrote up a recent blog post.

function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); + return isFileOfExtension(fname, ".ts") || isFileOfExtension(fname, ".js"); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.