TypeScript Developer interview question
Write a TypeScript function that safely parses unknown JSON into a typed object.
Hands-on Asked in Frontend Engineer · Full Stack Engineer interviews
Summary
Treat the input as unknown and validate it at runtime before trusting the type: either a type guard you write or
a schema library such as Zod, which validates and infers the static type from one schema. Return a result type
instead of throwing so callers must handle the failure.
Keep reading with a membership
The full answer with examples, key points and comparisons is part of the membership, along with every other interview answer, progress tracking and Daily Review. Most-asked answers stay free to read.
More TypeScript Developer questions
- What are the differences between `interface` and `type` aliases?
- What are generics and how do constraints work?
- What is structural typing in TypeScript?
- Explain `any`, `unknown` and `never`.
- What is type narrowing and what techniques does TypeScript support?
- What are discriminated unions and why are they powerful?
- What is TypeScript and what problems does it solve?
- Which built-in utility types do you use most, and what do they do?