What the compiler does: types are erased
Comes up in: Recruiter screen, JavaScript
This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.
What it covers
- type checking vs emitting JS
- types erased at runtime (no runtime checks)
- structural typing in one picture
tsc --noEmitwith a bundler doing the transpile- Node's built-in type stripping (fact) and
erasableSyntaxOnly
Words you will know
What you will practise
- show code that type-checks but fails at runtime (and why)
Interview questions this answers
- Does TypeScript check types at runtime? How do you validate data at runtime?
- What is structural typing? How is it different from nominal typing?