Compiler and editor workflow
Concept and syntax
An editor can underline errors using its TypeScript language service. The compiler command tsc --strict --noEmit main.ts independently checks a file without writing JavaScript. Run tsc --version to identify the compiler used by the command; editor and terminal can use different versions or configurations. Save the file, compare diagnostic codes and settings, correct the source, then check again. An editor without a red underline is not proof that the terminal build passes.
Working example
Compile standalone examples in a fresh directory with tsc --strict --target ES2022 --module commonjs --noEmitOnError main.ts, then node main.js.
Expected output (one line per log):
15Common mistake
Intentionally invalid; check this snippet separately. Do not run it.
Expected compiler diagnostic: TS2322. Changing the editor theme cannot fix TS2322. Change the incompatible initializer and recheck the saved file.
Practice and recap
Check the valid and invalid files with --noEmit. Record the version and diagnostic code; compare with your editor if one is available.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Compiler and editor workflow — knowledge check
Check the concept, apply it to a new choice, and interpret a compiler diagnostic.
Which command checks without producing JavaScript?
Editor and terminal disagree. What should you check first?
What explains TS2322 in this saved file?
let price: number = "12";