TypeScript Interview Questions
TypeScript interview questions for junior, middle and senior developers, with what to listen for in each answer.
Junior TypeScript interview questions
What is the difference between an interface and a type alias?
Look for: both describe object shapes; interfaces can be merged and extended, type aliases can describe unions, tuples and mapped types.
What is the difference between any and unknown?
Look for: any switches type checking off; unknown forces you to narrow the type before using the value.
Middle TypeScript interview questions
How does type narrowing work?
Look for: typeof, instanceof, in checks, discriminated unions and custom type guards.
When would you use generics?
Look for: reusable functions and components that keep the relationship between input and output types, with constraints via extends.
Senior TypeScript interview questions
How would you type an API client end to end?
Look for: generated types from an OpenAPI or GraphQL schema, runtime validation at the boundary and shared types between client and server.
How would you migrate a large JavaScript codebase to TypeScript?
Look for: allowJs, gradual strictness, typing the most shared modules first and tracking progress in CI.
More interview questions
Question sets for other developer roles and skills, grouped by seniority.