TypeScript Interview Questions: Answer Notes for Hiring Managers
Every TypeScript type is gone by the time the code runs. The handbook puts it plainly: type annotations never change the runtime behavior of a program. Source: TypeScript Handbook, The Basics That single fact explains most TypeScript defects in production, because the compiler checks the data it was told about, while carriers, browsers and other services send whatever they send. Useful TypeScript interview questions find out whether a candidate knows where the types stop being true.
The 13 questions below use one example system: a freight tracking platform that receives status webhooks from carriers, shows shipments in a web dashboard and publishes an SDK that customers use to pull tracking data into their own systems. Notes after each question describe what a solid answer usually contains. Treat them as a basis for discussion. A candidate who disagrees with a note and backs it up may be the one to hire. Interviews give you evidence about how someone reasons, and how they perform on your codebase is the real evidence.
Type System Judgment Questions
These questions test whether the candidate uses the type system to describe the domain or to silence compiler errors.
1. When Would You Use any, unknown and never?
A clear answer: unknown for values whose shape you have not checked yet, such as a parsed request body, because the compiler forces a check before use. never for states that should be impossible, such as the default branch of an exhaustive switch. any switches off checking for that value and everything derived from it, so it belongs only at the edges of untyped code, ideally with a comment saying why.
Ask how many any annotations their last codebase had and what they did about them. Candidates who tracked and reduced that number have usually thought about this beyond the interview.
2. How Would You Model a Shipment’s Status?
Look for a discriminated union: each status, such as in transit, held at customs, delivered or exception, is its own type with a shared literal field and only the data that status carries. A delivered shipment has a delivery time and a signer; a customs hold has a reason and a broker reference. A switch on the shared field narrows to the right type, and assigning the leftover case to never turns a forgotten status into a compile error. Source: TypeScript Handbook, Narrowing
The weaker model is one object with a status string and a dozen optional fields, which forces non-null assertions everywhere and lets impossible combinations compile.
3. What Is the Risk in a Custom Type Guard?
The compiler trusts a type predicate. A function declared to return shipment is DeliveredShipment narrows the type wherever it returns true, and nothing checks that its body matches that claim. If the guard tests the wrong field, every caller is wrong in a way the compiler endorses.
Good candidates keep guards small, test them directly and prefer validating the whole value with a schema at the boundary over scattering hand-written guards through the code.
4. When Do You Use satisfies Instead of a Type Annotation or as?
satisfies checks that an expression matches a type without changing the type TypeScript infers for it. Source: Microsoft TypeScript blog, Announcing TypeScript 4.9 That suits a lookup table of carrier codes, where you want to confirm every entry has the right shape while keeping the literal keys for autocompletion. An annotation widens the value to the declared type. as overrides the checker, which is why a candidate should treat it as a claim they are personally vouching for.
Runtime Boundary Questions
This group carries the most weight, because it is where TypeScript stops protecting you.
5. A Carrier Sends a Webhook. How Do You Type the Payload?
A strong answer starts with unknown and validates the payload against a schema before anything else touches it, then derives the TypeScript type from that schema so the two cannot drift apart. Payloads that fail validation go to a quarantine queue with the raw body kept for diagnosis, rather than crashing the handler or being half-processed.
Ask what happens when a carrier adds a field or changes a date format without notice. Integration work exposes this constantly. On a Salesforce integration for a video platform, our engineer built TypeScript middleware on AWS to handle high-volume webhooks and, acting as the platform’s first external customer, exposed gaps in the client’s webhook documentation and authentication logic.
6. What Does JSON.parse Return, and Why Does It Matter?
It returns any, so whatever type the code assigns afterward is a claim, not a check. Dates are a useful follow-up: an estimated delivery time arrives as a string, and code that types it as Date compiles fine and then throws when someone calls a Date method on it. Candidates who have hit this tend to mention it before you ask.
7. How Do You Keep Types in Sync Between the API and Its Clients?
Common answers include a shared types package in a monorepo, generating client types from an OpenAPI description, or an end-to-end typed RPC layer. All of them help. The follow-up is version skew: the web dashboard deploys with the API, but customers’ SDK installations do not. Shared types catch mismatches at build time, and only additive, backward-compatible API changes protect clients that are already deployed.
Generics and API Design Questions
These questions matter most for engineers who will write code that other engineers, or customers, call.
8. Write the Type for a Function That Groups Shipments by Any Key.
A reasonable signature takes an array of T and a function from T to a string key, and returns a record of string keys to arrays of T. Some candidates constrain the key to a property name with keyof instead, which is fine if they can explain the trade-off.
Then ask when generics make code worse. Good answers mention signatures that need three type parameters and a conditional type to express something a plain overload would say clearly, and the cost that puts on the next reader.
9. You Publish an SDK. Which Type Changes Break Your Customers?
Breaking changes in types are easy to ship by accident. Making an optional parameter required, narrowing an accepted parameter type, widening a returned type and renaming an exported type all break customer builds. One that candidates often miss: adding a new member to a union the SDK returns, such as a new shipment status, breaks any customer code with an exhaustive switch over that union. A senior answer treats exported types as part of the public API under semantic versioning.
Configuration and Migration Questions
10. Which Compiler Settings Would You Turn On for a New Project?
strict is the baseline, since it turns on the strictness flags together, including noImplicitAny and strictNullChecks, as the handbook describes. Experienced candidates often add noUncheckedIndexedAccess, which adds undefined to values read through an index signature, such as a carrier lookup keyed by code. Source: TSConfig reference, noUncheckedIndexedAccess It is a separate flag that strict does not enable, and it catches a class of missing-key bugs at the cost of more explicit checks.
11. How Would You Migrate a Large JavaScript Codebase to TypeScript?
Look for an incremental plan. Allow JavaScript and TypeScript side by side, convert the modules at the boundaries first, where incorrect data does the most damage, and require new files to be TypeScript. Track the counts of any and of suppression comments so progress is visible, and tighten strictness by directory rather than all at once.
A plan that pauses feature work for a big-bang conversion is the one to question. It concentrates risk, and the business rarely tolerates the pause long enough to finish.
12. Type Checking Takes Several Minutes in CI. What Do You Look At?
Good answers separate transpiling from type checking: many build tools strip types without checking them, so the check can run as its own parallel step. Then they look at incremental builds and project references, and at a small number of very complex types that the compiler struggles to resolve. Skipping library checks speeds things up, and a candidate should say what it gives up.
A Code Review Question
13. What Would You Flag in This Pull Request?
Show a short webhook handler that does four things: casts JSON.parse output with as Shipment, calls a Date method on an optional estimated delivery field with a non-null assertion, suppresses an error on the next line with @ts-ignore, and annotates a caught error as any before reading its message property. Ask the candidate to rank what they find.
The unchecked cast at the boundary is the most serious, because everything downstream trusts it. The non-null assertion on optional carrier data comes next. A strong reviewer prefers @ts-expect-error over @ts-ignore, since it fails once the error it hides is gone, and notes that strict mode already types catch variables as unknown through useUnknownInCatchVariables, so annotating the error as any throws that check away; the handler should narrow it with instanceof Error before reading message. Source: TSConfig reference, useUnknownInCatchVariables
A Practical Assessment
Give the candidate three sample carrier payloads, one of them malformed, and 45 to 60 minutes to write the validation, the derived types and a handler that routes bad payloads to quarantine, with tests. Follow it with a conversation about what they would change if a fourth carrier used a different date format. The code shows their habits; the conversation shows whether they understand them. Angular projects are TypeScript from the first file, so if that is your framework, pair this exercise with our Angular interview questions.
How Should You Score TypeScript Answers?
A four-point scale helps each interviewer organize specific evidence before discussing a candidate. The scale structures the debrief; it is no forecast of job performance.
| Score | What it sounds like |
|---|---|
| 1 | Defines features but cannot say when to use them; reaches for any or as to make errors go away |
| 2 | Uses the type system correctly inside the program; trusts external data |
| 3 | Validates at boundaries, models the domain with unions, explains compiler settings |
| 4 | Designs public types as an API, plans migrations, anticipates version skew without prompting |
Write the expected answer next to each question before the first interview, and record the evidence behind every score.
Red Flags in TypeScript Interviews
Follow up when a candidate treats types as runtime checks, uses as to resolve compiler errors, models states with optional fields instead of unions, relies on a hand-written guard nobody tests, or proposes turning strict mode off to get a migration moving. Any one of these can come from habit in a codebase with weak standards, so ask what they would do with a free choice before you draw a conclusion.
How We Think About TypeScript Engineers at Gun.io
TypeScript often runs on both sides of a product, in the browser and in Node.js services, which suits our full-stack-first view: one engineer who can carry a typed contract from the database to the dashboard avoids a handoff on every change. When we look at a TypeScript engineer for an engagement, we care less about type-level tricks and more about whether their types describe real data and whether they validate it where it enters. For Node.js services specifically, our Node.js developer interview questions cover the runtime side.
Gun.io assesses technical capability and professional fit in human interviews, and we keep assessing after an engagement begins, because the work is the real test. That is the lens we apply when we match TypeScript engineers to a client’s codebase, whether they join an existing team or own a scoped piece of work.
Frequently Asked Questions
Should I Ask JavaScript Questions in a TypeScript Interview?
Yes, because TypeScript compiles to JavaScript and runs with JavaScript’s behavior. Asynchronous code, closures, equality and the event loop all still apply, and a candidate who knows the type system but not the runtime underneath it will write code that type-checks and still fails.
How Do I Ask Advanced TypeScript Questions Without Rewarding Puzzles?
Ask candidates to read and explain a mapped or conditional type from real library code rather than write a type-level puzzle from scratch. Explaining what a type does, and when it would confuse a teammate, is closer to the work than producing clever types under observation.
Are Enums Still Worth Asking About?
Briefly. Enums generate JavaScript at runtime, unlike most TypeScript syntax, which matters for tools that run TypeScript by stripping types. Many teams prefer unions of string literals for that reason, and a candidate who can explain the trade-off either way is showing current knowledge.
What Should I Ask a Junior TypeScript Developer?
Ask them to type a small function, explain the difference between unknown and any, and model two or three states as a union. Junior candidates who say when they would reach for as, and why it worries them, have a sound instinct to build on.
Does TypeScript Reduce the Need for Tests?
It removes some tests and none of the important ones. Types catch mismatched shapes inside the program; tests check behavior, business rules and what happens with real input that the types assumed away. Engineers who use types as a reason to skip boundary tests are relying on checks that disappear at runtime.
Does AI-Generated TypeScript Need a Different Review?
It needs the same review with attention on a few habits. Generated code often satisfies the compiler with casts, non-null assertions and any where the honest fix is validation or a better type, so search the diff for those first. A candidate who reviews generated code this way is showing the judgment the role needs.
Trust Types Only as Far as the Boundary
Hire the TypeScript engineer whose types match the data, who validates where data enters, and whose work on your codebase confirms what the interview suggested. If TypeScript is where your next hire will spend their days, tell us about the typed system you need help with, where its data comes from and which services and clients share its types.