· Jake Worth
Compiling TypeScript with tsc watch
Watch and recompile any TypeScript file on write, no project required, with
--watch:
$ tsc <your-file>.ts --watchThis is a great hack to tell if you’ve written compilable TypeScript, without other tooling. It returns:
Starting compilation in watch mode.Now, when you write your tutorial file, the compiler compiles, giving near-instant feedback.
Something that trips people up: without a tsconfig.json, tsc uses the
compiler’s default options, and it still emits .js next to your .ts. Watch
mode will keep rewriting that output on every write.
If you only want a compile check and no artifacts, add --noEmit:
$ tsc <your-file>.ts --watch --noEmitThat keeps the same feedback loop without any collateral JavaScript file creation.