completefrontend

How to prepare for a TypeScript interview

Get the core of the type system solid, practice explaining, predicting, and writing types, and say your answers out loud. Here's what to study, how to practice each kind of question, and a two-week plan.

Four chips: explain a concept, predict the types, write the code, and say it out loud

A music exam has three parts. You play the scales you've drilled, you play a piece you've prepared for weeks, and then the examiner puts a page in front of you that you've never seen and asks you to sight-read it. Each part needs its own kind of practice, and being great at one doesn't cover the others.

To prepare for a TypeScript interview, get the core of the type system solid, practice the three kinds of question (explaining an idea, predicting what the compiler reports, and writing a type), cover the frontend cases like server data and React props, and practice saying your answers out loud. The rest of this post turns that into a plan.

What gets asked in a TypeScript interview?

TypeScript questions come in three shapes, and the TypeScript interview questions on this site are sorted the same way:

  • Explain a concept. "What's the difference between any and unknown?" or "When would you use an interface over a type?" You answer in words, with a small example.
  • Predict the types. You get a few lines of code and say what TypeScript infers, which lines it marks, and sometimes what the code logs when it runs.
  • Write the code. You write a type or a typed function, like your own version of Pick, or a type guard that checks a server reply.

Some questions mix TypeScript and JavaScript. When a question asks what the code logs, the answer is pure JavaScript, because the types are removed before it runs. If that half is shaky, the JavaScript interview questions are worth a pass too.

Which TypeScript topics should you study?

Learn these in order. Each one leans on the ones before it:

  1. The basics. Type annotations & inference, any, unknown & never, literal types, and type aliases & interfaces. You should be able to answer these without a pause.
  2. Narrowing. Narrowing with typeof & truthiness, discriminated unions, type predicates, and as const & satisfies.
  3. Objects. Structural typing and excess property checks, which explain plenty of surprising errors.
  4. Generics. Generic functions, generic constraints, and keyof & typeof.
  5. Types from types. Utility types, mapped types, conditional types, and writing your own utility types. Many write-the-code questions live here.
  6. Frontend code. Typing fetch & JSON, typing errors, typing the DOM, and typing React components.
  7. Projects. Strict mode options, type checking vs type stripping, and migrating JavaScript to TypeScript, for the "how would you set this up?" questions.

You don't need to memorize the compiler's internals. You need to know what each feature is for, when you'd pick it, and what it can't do.

How do you practice each kind of question?

Three cards for the three kinds of TypeScript interview question. Explain a concept: say what it is, why it exists, and show an example. Predict the types: let size = "small" is string, and const fixed = "small" is the literal "small". Write the code: MyPick, written with keyof and a mapped type, tested with a type test.
Each kind of question needs its own kind of practice.

Concept questions

Answer in three short steps: what it is, why it exists, and a two-line example. For any vs unknown, that's: both accept any value, any turns checking off, and unknown makes you check the value before you use it, so a bad server reply can't slip through. Then expect a follow-up, like "so when would you ever use any?" Every answer on the questions page ends with what an interviewer might ask next, so you can practice those too.

Predict-the-types questions

Write your guess down before you look. That's the whole trick. If you check first, you'll always feel like you knew it. Here's a small one:

let size = "small";
// size: string

const fixed = "small";
// fixed: "small"

let can be given a new string later, so TypeScript widens its type to string. const can't change, so it keeps the exact literal type "small". On the site, these questions show the code without errors until you press Check it with TypeScript, so you can guess first. In your own editor, point at a name only after you've said the type out loud.

Write-the-code questions

Start with the simplest type that works for the main case, then handle the edge cases one at a time. Say each step as you go. Here's a version of Pick:

type MyPick<T, K extends keyof T> = { [P in K]: T[P] };

type Todo = { title: string; description: string; done: boolean };
type Preview = MyPick<Todo, "title" | "done">;
// { title: string; done: boolean }

// @ts-expect-error "titel" isn't a key of Todo
type Typo = MyPick<Todo, "titel">;

K extends keyof T limits the keys to ones Todo really has, so the typo is an error. The mapped type then copies each picked key with its type, T[P]. The last two lines are a test: // @ts-expect-error fails if the line after it compiles. The answers on this site test their solutions the same way, so you can see what "done" looks like.

What should you do during the interview?

  • Say what you expect before you run anything. "I think this is string | undefined, because find can miss." Being wrong out loud and fixing it shows more than silence.
  • Start simple, then tighten. A working type you improve beats a perfect one you never finish.
  • Know where the types stop. If data comes from a server or localStorage, say it needs a runtime check, because types are removed before the code runs.
  • Don't silence errors to move on. Reaching for any or as to make a red line go away hides the very thing the question is about. If you do use one, say why.
  • Read errors from the bottom up. In a long error, each line explains the one above it, so the last line names the real mismatch. Reading type errors shows how.

What does a two-week plan look like?

Here's one way to fit it into two weeks, about an hour a day. Stretch it if you have more time.

Days Learn Practice
1-3 Inference, special types, unions, interface vs type Easy concept questions in type basics and objects
4-6 Narrowing, discriminated unions, satisfies Predict-the-types questions on narrowing
7-9 Generics, keyof, utility types, mapped types Write your own Pick, Omit, and Partial
10-12 Fetch, errors, the DOM, React props and hooks Frontend questions, written and said out loud
13-14 Whatever your notes say you missed A timed mock round, then redo your weakest questions

Keep a list of every question you got wrong and why. That list is your plan for the last two days.

Where to go next

Start with the easy questions in TypeScript interview questions, and open a lesson from the TypeScript course whenever an answer doesn't click. When you're ready to try a whole round, a mock interview gives you a timed TypeScript round with an AI interviewer who asks follow-ups and writes a scored report.

Written by Shrikanth PS

Senior Software Engineer at Microsoft, working on Copilot Enterprise, with more than nine years in frontend engineering.