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.
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).
The tsc command envokes the TypeScript compiler. When no command-line options are present, this command looks for the tsconfig. json file. If no tsconfig.
TypeScript is a superset of Javascript that compiles to plain JavaScript. So TypeScript needs to be compiled to Js in order to run that's why it doesn't show runtime errors.
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
First install ESLint (you need npm installed in your system):
npm i -g eslint
Execute ESLint to check files:
eslint file1.ts file2.ts
or:
eslint lib/**
ESLint supports a lot of options for more advanced case uses, check the docs.
If its just syntax checking you are after then you can use a linter like tslint which can be run from the command line or via many build tools
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