Compilation
Common mistakes
- The TypeScript build succeeds with type errors because the bundler only strips types.
Key points
- The build runs a real type check, such as
tsc --noEmit, since tools that only strip types do not report type errors. - Compiled output folders are listed in
.gitignore, not committed.
Interview questions
Compiled vs interpreted language: what is the difference?
A compiled language is translated before it runs. An interpreted one is read and run by an interpreter, though many modern runtimes mix both.
Is JavaScript compiled or interpreted?
Both. Engines parse JavaScript to bytecode, interpret it and JIT-compile hot code to machine code while the program runs.
Is TypeScript compiled?
Yes, it is compiled to JavaScript. By default tsc still emits files when there are type errors unless noEmitOnError is set.