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

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


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