ExtraBrain Interview Questions
TypeScript Interview Questions for 2026, With Tested Answers
Short answer
A good TypeScript interview tests whether you can make the compiler catch real bugs: narrowing with discriminated unions and exhaustive never checks, generics constrained with keyof, conditional and mapped types, satisfies versus annotations, and the boundary where types disappear at runtime. Expect questions on TypeScript 7, the native Go-based compiler released in July 2026, and on running TypeScript directly in Node.js.
TypeScript interview questions for 2026: narrowing, generics, conditional and mapped types, satisfies, TypeScript 7 and Node type stripping, with tested code.
TypeScript questions split into two kinds. Some check vocabulary (“what is unknown?”). The better ones hand you a type that lets a bug through and ask you to tighten it. Strong candidates answer the second kind by showing the compiler error they want and the code that produces it.
The tooling also changed under everyone’s feet this year. TypeScript 6.0 shipped in March 2026 as the last release built on the JavaScript codebase, and TypeScript 7.0 followed on July 8, 2026 as a native port written in Go. Every snippet below passes tsc --strict and runs directly in Node.js. Lines marked @ts-expect-error are lines the compiler must reject.
Type system basics
type or interface?
Both describe object shapes. Interfaces can be reopened and merged, which libraries use to let you extend their types, and extends on interfaces gives clearer errors than large intersections. Type aliases can name anything: unions, tuples, mapped and conditional types. A reasonable team rule is interfaces for public object shapes and type aliases for everything else. Interviewers mostly want to hear that you know declaration merging exists.
any, unknown and never?
any turns checking off in both directions. unknown accepts any value but lets you do nothing with it until you narrow it, which makes it the right type for parsed JSON and caught errors. never is the type with no values: the return type of a function that always throws, and the leftover type when every union member has been handled.
Show narrowing with a discriminated union.
type Shape = | { kind: "circle"; radius: number } | { kind: "square"; side: number };
function area(shape: Shape): number { switch (shape.kind) { case "circle": return Math.PI * shape.radius ** 2; case "square": return shape.side ** 2; default: { const unreachable: never = shape; // fails to compile if a member is unhandled return unreachable; } }}
console.log(area({ kind: "square", side: 3 })); // 9The narrowing chapter of the handbook explains both halves: a shared literal property such as kind lets TypeScript narrow each branch, and because nothing is assignable to never, adding a triangle member makes the default branch a compile error until you handle it.
Write a type guard that filters out null and undefined.
function isDefined<T>(value: T | null | undefined): value is T { return value != null;}
const raw: (string | null | undefined)[] = ["a1", null, "b2", undefined];const ids: string[] = raw.filter(isDefined);console.log(ids); // [ 'a1', 'b2' ]The return type value is T is a type predicate. Without it, filter would return the original union type. Mention that a predicate is a promise you make to the compiler: if the body is wrong, TypeScript believes you anyway.
Generics and type-level questions
Type a function that plucks a property from a list.
function pluck<T, K extends keyof T>(items: T[], key: K): T[K][] { return items.map((item) => item[key]);}
const users = [ { name: "Ada", age: 36 }, { name: "Linus", age: 28 },];const names: string[] = pluck(users, "name");console.log(names); // [ 'Ada', 'Linus' ]
// @ts-expect-error "email" is not a key of the user typepluck(users, "email");K extends keyof T limits the key to real property names, and the indexed access type T[K] makes the return type follow the key: strings for "name", numbers for "age".
Explain conditional types, infer and mapped types.
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;type ToArray<T> = T extends unknown ? T[] : never; // distributes over unions
type DeepReadonly<T> = { readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];};type Getters<T> = { [K in keyof T as `get${Capitalize<string & K>}`]: () => T[K];};
type Equal<X, Y> = (<V>() => V extends X ? 1 : 2) extends <V>() => V extends Y ? 1 : 2 ? true : false;const unwrapped: Equal<UnwrapPromise<Promise<number>>, number> = true;const distributed: Equal<ToArray<string | number>, string[] | number[]> = true;
interface Config { port: number; db: { host: string };}const config: DeepReadonly<Config> = { port: 8080, db: { host: "localhost" } };// @ts-expect-error host is read-only at every depthconfig.db.host = "prod";
const getters: Getters<{ port: number }> = { getPort: () => 8080 };console.log(unwrapped, distributed, getters.getPort()); // true true 8080Walk through each piece. infer U captures part of a matched type. A conditional type applied to a naked type parameter distributes over a union, so ToArray<string | number> becomes string[] | number[] rather than (string | number)[]. Mapped types rebuild an object type key by key, and the as clause renames keys. The Equal helper is a common idiom for compile-time tests of types. Add the honest caveat: readonly is compile-time only, so the assignment above would still run at runtime.
How would you write Partial and Pick yourself?
Both are mapped types from the standard library. Partial<T> is { [K in keyof T]?: T[K] }, which adds the optional modifier to every key, and Pick<T, K extends keyof T> is { [P in K]: T[P] }, which keeps only the listed keys. Omit is built from Pick and Exclude, and ReturnType uses a conditional type with infer on a function type. Writing one from memory is a fast way to show you understand mapped types, and interviewers often follow up with “now make it deep,” which leads straight to the recursive DeepReadonly above.
What are excess property checks?
TypeScript is structural: any object with the required properties fits a type, and extra properties are normally fine. The exception is a fresh object literal assigned directly to a typed target. There, an unknown property such as { name: "Ada", emial: "x" } is reported as an error, because it is probably a typo. Assign the same object through an intermediate variable and the check no longer applies. Candidates who can explain why the “same” object passes in one place and fails in another show they understand structural typing.
Why can’t a readonly string[] be passed where string[] is expected?
A function that takes string[] is allowed to push or sort in place, so handing it a read-only array would break the promise. The reverse is fine: a mutable array can go anywhere a read-only one is expected. Accept readonly T[] in function parameters you don’t mutate, and callers can pass either kind.
What does satisfies do that an annotation doesn’t?
type Route = { path: string; auth: boolean };
const routes = { home: { path: "/", auth: false }, admin: { path: "/admin", auth: true },} satisfies Record<string, Route>;
console.log(routes.admin.path); // /admin// @ts-expect-error "settings" is not a key: satisfies kept the precise typeroutes.settings;
const annotated: Record<string, Route> = routes;console.log(annotated.settings); // undefined, yet it type-checks as RouteThe TypeScript 4.9 release notes describe satisfies as checking that a value matches a type without changing the value’s inferred type. An annotation replaces the inferred type, so the precise keys are lost, and here the annotated version happily types a missing route as present. (The noUncheckedIndexedAccess option would catch that case too.)
Runtime boundary questions
Your API types say User, but production sends something else. Why didn’t TypeScript catch it?
Types are erased; nothing checks a network response unless you write the check. An as User cast is a claim, not a validation. Parse untrusted input as unknown, then validate it with a hand-written type guard or a schema library, and derive the static type from the schema so the two can’t drift apart.
Why might a team ban enums?
const Status = { Active: "active", Banned: "banned" } as const;type Status = (typeof Status)[keyof typeof Status]; // "active" | "banned"
function label(status: Status): string { return status === Status.Active ? "OK" : "Blocked";}
console.log(label("banned"), Object.values(Status)); // Blocked [ 'active', 'banned' ]Enums generate JavaScript, so they aren’t erasable syntax. The Node.js TypeScript documentation says type stripping, enabled by default since v23.6.0 and v22.18.0 and stable since v25.2.0 and v24.12.0, removes types without type checking and rejects syntax that needs code generation: enums, namespaces with runtime code, parameter properties and import aliases. The erasableSyntaxOnly compiler option flags those constructs. An as const object plus a union type gives the same autocomplete and works everywhere.
What changes with TypeScript 7?
| Setting | TypeScript 6.0 | TypeScript 7.0 |
|---|---|---|
strict default | true | true |
target: es5 | Deprecated | Removed |
baseUrl | Deprecated | Removed |
moduleResolution: node10 | Deprecated | Removed |
| Compiler written in | TypeScript | Go |
| Programmatic API | Available | Not in 7.0 |
The 7.0 announcement reports full builds typically 8 to 12 times faster, gives @typescript/typescript6 for running 6.0 side by side, and notes that 7.0 ships without a programmatic API, so tools that depend on it, such as Volar-based checkers for Vue, Astro and Svelte, still use 6.0 for now. A good interview answer: upgrade CI type-checking first, keep editor and framework tooling on 6.0 until it supports 7.
Practice explaining compiler errors
Type questions go well when you can read an error message aloud and say what it protects you from. Practice that with real errors from your own code, and if you rehearse with ExtraBrain, its transcript shows where your explanation got vague. Our JavaScript interview questions cover the runtime side that TypeScript sits on, and the frontend developer mock interview page has more prompts. ExtraBrain is for preparation and your own notes; follow each employer’s rules on AI during interviews.
Sources (checked November 23, 2026)
- TypeScript blog, Announcing TypeScript 7.0
- TypeScript blog, Announcing TypeScript 6.0
- TypeScript blog, release announcements
- TypeScript handbook, Narrowing
- TypeScript 4.9 release notes
- Node.js documentation, Modules: TypeScript
FAQ
Is TypeScript 7 safe to use in interviews?
Use whatever the interview environment provides. Most coding platforms run a stable compiler, and the language features above behave the same in 6.0 and 7.0.
Do I need to write advanced type-level code?
For library or platform roles, often. For product roles, expect generics, narrowing and utility types such as Partial, Pick and Record, plus one question that goes a level deeper.
Should I turn on strict in a take-home?
Yes. It is the default in TypeScript 6.0 and 7.0, and turning it off looks like hiding errors.