Search code examples
typescriptsyntaxcompilationverificationsyntax-checking

How to check TypeScript code for syntax errors from a command line?


I have a code that generates TypeScript classes, and as a build/test step, I would like to check the generated files for syntax correctness.

I have looked at TypeScript compiler options but see no such option.

  • How can I check the syntax?

I don't want a full compilation because the referred types are not reachable at that build step (they are in a different module to which the generated sources are added later).


Solution

  • The tsc --noEmit is what you're searching.

    Do not emit compiler output files like JavaScript source code, source-maps or declarations.

    source TSDocs


    If you want lint code as well as check types on CI use tsc --noEmit && eslint

    source Stackoverflow comment