TypeScript Interview Questions

18 TypeScript interview questions with worked answers, complexity notes, and runnable code you can edit in the browser — ordered easy to hard so you build up steadily. Free, no signup. Open any question for the full answer.

Modeling intent so bugs fail at compile time

TypeScript interviews are not about memorizing utility types — they are about judgment. The good use of the type system encodes what your code actually means, so a whole class of mistakes becomes unrepresentable and fails at compile time instead of in production. The bad use over-types everything, fights the compiler, and produces generics so clever nobody can change them. Interviewers are listening for where you draw that line.

Start with the everyday tools and know exactly when each earns its place. Generics let a function preserve the relationship between its input and output types rather than throwing that information away with any. Discriminated unions model a value that is one of several shapes — a request that is loading, loaded, or errored — and give you exhaustive checking so adding a new state surfaces every place that must handle it. Narrowing is how you earn access to a value’s specific type through control flow, type guards, and in checks.

The utility types — Partial, Pick, Omit, Record, ReturnType — are shortcuts for transformations you would otherwise write by hand, and knowing them signals fluency. But the deeper signal is knowing when not to reach for the type system at all: when a simpler type is clearer, when inference already has it covered, and when a runtime check is the honest tool because the data crosses a boundary the compiler cannot see. These questions move from the foundations into that harder territory of type-level modeling and restraint.

Easy

Medium

Hard

Other topics

HTML/CSS · Browser · JavaScript · React · System Design · Accessibility · Web Performance · Testing · Networking/Security · DSA

← Search all 265 questions