hardConceptMidSeniorStaff
Where does TypeScript stop protecting you, and what do you do at those points?
TypeScript stops protecting you at runtime boundaries such as JSON, HTTP requests, local storage and third-party packages. Validate untrusted input at the boundary, then let static types carry the trusted shape inside the app. It also connects type soundness to the point an interviewer is testing.
4 min readUpdated 2026-08-15
Answer
Short answer
TypeScript types disappear at runtime, so data from APIs, forms, files and external packages must be parsed or validated before use. After that boundary check, the validated value can safely flow through typed code.
Was this answer helpful?
Likely follow-ups
- You add noUncheckedIndexedAccess to a mature codebase and get 900 errors. How do you land it?
- Why is a user-defined type predicate a hole in the type system, and what changed in TypeScript 5.5?
- Object.keys on a typed object returns string[] rather than the key union. Is that a bug or a decision?
- How would you type the response of an endpoint you do not control, in a way that fails loudly rather than late?
Related questions
- Your endpoint takes a typed request body and it still crashed on a missing field. How is that possible when it compiled?mediumAlso on typescript and type-erasure4 min
- A churn model scores 0.94 AUC offline and barely beats the baseline in production. One of its strongest features is populated by a process that runs after the customer has already churned. Explain what happened and how you would fix it.mediumAlso on validation5 min
- Why would you bind configuration with @ConfigurationProperties rather than @Value, and how do you make a bad value fail at startup instead of at the first request?mediumAlso on validation4 min
- How do you make the compiler fail when somebody adds a new variant to a union you switch on?mediumAlso on typescript5 min