TypeScript · Junior · Question 2 of 75
Does TypeScript check types while the program is running?
- ✓Correct answer: No: types are erased at compile time; plain JS runs at runtime
- 2Yes: the compiler inserts checks before every function call
- 3Yes, but only for classes and interfaces with the
strictmodifier
Explanation
TypeScript is a development-time tool. If an API returns null instead of an object, types won't save you. For runtime checks, use typeof/instanceof and schema libraries (Zod, Valibot), from which you can also infer TS types.