Interview questions

TypeScript Interview Questions

17 TypeScript interview questions on types, interfaces, generics, narrowing and strict mode, with model answers for developers and interviewers.

TypeScript Interview Questions

What's here

17 TypeScript interview questions, grouped into 4 areas: basics, the type system, generics and utility types and configuration and practice. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.

  • Ask candidates to type a small, realistic function, such as an API response handler, rather than recite definitions
  • Probe any versus unknown; the answer shows how they treat untrusted data
  • Include one generics exercise for mid-level and senior roles
For hiring teams

Cohesyve finds, contacts and tests TypeScript candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.

Preparing for this interview yourself? Practise it free →

TypeScript interview questions are now standard for front-end, full-stack and Node.js developer roles. TypeScript adds static types to JavaScript, and interviewers want to see that a candidate uses the type system to catch bugs and model data, without fighting it or reaching for any. These questions cover the basics, the type system in depth, generics and utility types, and configuration. Candidates can use the 'what to look for' notes as model answers; interviewers can use them as a scoring guide.

Basics

The questions most TypeScript interviews open with.

  1. 1

    What problems does TypeScript solve compared with plain JavaScript?

    Why ask it

    A warm-up that shows whether the candidate understands the value, not only the syntax.

    What to look for

    Catching type errors at compile time, better editor tooling (autocomplete, refactoring), self-documenting code and safer large-scale changes. Strong candidates note that types are erased at compile time, so runtime data from APIs still needs validation.
  2. 2

    What is the difference between an interface and a type alias?

    Why ask it

    The most asked TypeScript question.

    What to look for

    Both can describe object shapes. Interfaces can be reopened and merged (declaration merging) and extended with extends; type aliases cannot be reopened but can express unions, intersections, tuples and mapped or conditional types. The TypeScript handbook suggests using interface until you need features of type. Team consistency matters more than the choice.
  3. 3

    What is the difference between any, unknown and never?

    Why ask it

    Shows whether the candidate writes type-safe code.

    What to look for

    any switches off type checking for that value. unknown accepts any value but forces you to narrow it before use, so it is the safe choice for untrusted input. never represents a value that cannot exist, used for exhaustive checks and functions that never return. noImplicitAny flags places where TypeScript falls back to any.
  4. 4

    What does strictNullChecks do?

    Why ask it

    Null and undefined errors are among the most common bugs.

    What to look for

    With strictNullChecks on, null and undefined are not assignable to other types, so you must check for them before using a value. The handbook recommends turning it on where practical. Mentions of optional chaining (?.) and nullish coalescing (??) show day-to-day fluency.
For hiring teams

Before the TypeScript interviews, see who can do the work

Cohesyve finds and contacts TypeScript candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.

The Type System

Deeper questions that separate everyday users from strong TypeScript developers.

  1. 5

    What is type narrowing? Name some ways TypeScript narrows types.

    Why ask it

    Narrowing is how safe code is written with unions.

    What to look for

    Refining a broader type to a more specific one within a code path: typeof and instanceof checks, the in operator, equality checks, truthiness checks, user-defined type guards (x is Foo) and discriminated unions.
  2. 6

    What is a discriminated union, and how do you make a switch exhaustive?

    Why ask it

    A powerful pattern for modelling state.

    What to look for

    A union where every member has a common literal property (kind: 'circle' | 'square') that TypeScript uses to narrow. An exhaustive switch assigns the value to a variable of type never in the default branch, so adding a new member causes a compile error until it is handled.
  3. 7

    What is the difference between union and intersection types?

    Why ask it

    Basic composition of types.

    What to look for

    A union (A | B) is a value that is one of the types; you can only use members common to both until you narrow. An intersection (A & B) combines types, so the value has all members of both. Intersections of conflicting primitive types become never.
  4. 8

    What does the satisfies operator do?

    Why ask it

    Checks whether the candidate keeps up with the language.

    What to look for

    Introduced in TypeScript 4.9, satisfies checks that an expression matches a type without changing the expression's inferred type. Example: a config object checked against Record<Key, string | number> while each property keeps its specific type, which a type annotation would widen.
  5. 9

    What are literal types and as const?

    Why ask it

    Common in modern TypeScript code.

    What to look for

    Literal types are exact values ('GET', 42). as const makes TypeScript infer the narrowest literal types and readonly properties for an object or array, useful for constant lookups and deriving union types from arrays.

Generics and Utility Types

Reusable typing, which most mid-level and senior interviews test.

  1. 10

    What are generics, and why use them? Write a generic function signature.

    Why ask it

    Generics are central to reusable typed code.

    What to look for

    Type parameters let a function or type work with many types while preserving the relationship between input and output, for example function first<T>(items: T[]): T | undefined. Constraints (T extends { id: string }) restrict what can be passed. Using any instead loses the type information.
  2. 11

    Explain Partial, Required, Pick, Omit and Record.

    Why ask it

    Built-in utility types appear in most codebases.

    What to look for

    Partial makes all properties optional; Required makes them all required; Pick keeps selected properties; Omit removes selected properties; Record builds an object type from a set of keys and a value type. A practical example: Partial<User> for an update payload.
  3. 12

    What is keyof, and what is a mapped type?

    Why ask it

    Tests understanding of how utility types are built.

    What to look for

    keyof T gives a union of T's property names. A mapped type iterates over keys to build a new type, for example { [K in keyof T]?: T[K] }, which is how Partial is defined. Strong candidates can write a small mapped type themselves.
  4. 13

    What are conditional types, and what does ReturnType do?

    Why ask it

    Advanced but common in library code.

    What to look for

    Conditional types choose a type based on a condition (T extends U ? X : Y), often with infer to extract a type. ReturnType<F> gives the return type of a function type, useful to keep types in sync with implementation.

Configuration and Practice

How the candidate uses TypeScript on a real project.

  1. 14

    Which tsconfig options do you consider essential?

    Why ask it

    Shows experience setting up projects.

    What to look for

    strict (which enables noImplicitAny, strictNullChecks and related checks), target and module settings that match the runtime, moduleResolution, paths if used, and noUncheckedIndexedAccess or similar extra checks where the team agrees. Explaining why matters more than listing flags.
  2. 15

    How do you type data that comes from an API?

    Why ask it

    Types are erased at runtime, which catches out many developers.

    What to look for

    Treat incoming data as unknown and validate it at the boundary with a schema library or hand-written guards, or generate types from an API schema. Casting with as only silences the compiler and can hide runtime errors.
  3. 16

    How would you migrate a JavaScript codebase to TypeScript?

    Why ask it

    A common real-world project.

    What to look for

    Incrementally: allowJs, convert files gradually starting from leaf modules or shared types, enable stricter options over time, add types for third-party libraries, and track progress. Avoid a big-bang rewrite.
  4. 17

    When is using as or a non-null assertion (!) acceptable?

    Why ask it

    Over-use of assertions undermines type safety.

    What to look for

    Rarely, and only when the developer knows more than the compiler and can justify it, such as after a check TypeScript cannot follow. Prefer narrowing or better types. Frequent assertions are a code smell.

Running the interview well

  • 1Ask candidates to type a small, realistic function, such as an API response handler, rather than recite definitions
  • 2Probe any versus unknown; the answer shows how they treat untrusted data
  • 3Include one generics exercise for mid-level and senior roles
  • 4Ask how they validate data at runtime, since types are erased at compile time
  • 5Check tsconfig experience for candidates who will set up or maintain projects
  • 6Give credit for readable types over clever ones

Common questions

What are the most common TypeScript interview questions?

Interface versus type, any versus unknown versus never, strict mode and strictNullChecks, type narrowing, discriminated unions, generics, utility types such as Partial, Pick and Omit, and how to type API data.

Do I need to know JavaScript well for a TypeScript interview?

Yes. TypeScript compiles to JavaScript and interviews often include JavaScript questions on closures, promises, async/await and the event loop. Strong JavaScript fundamentals come first.

How should I prepare for a TypeScript interview?

Turn on strict mode in a small project, model some data with unions and generics, write a few type guards and a discriminated union with an exhaustive switch, and read the TypeScript handbook sections on narrowing and utility types.

Should I use interface or type?

Either works for most object shapes. The TypeScript handbook suggests interface until you need features of type, such as unions. Follow your team's convention and be consistent.

Are TypeScript questions different for React roles?

React roles add questions on typing props, state, events, hooks and generic components. The core type system questions stay the same.

For hiring teams

Save these questions for the TypeScript candidates who can do the work

Cohesyve takes your TypeScript job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.

1,500+

assessments completed

50%

faster time-to-hire

5 min

from JD to assessment

14-day free trial · 10 candidates · Not charged until the trial ends

For job seekers

Preparing for a TypeScript interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.

Practise a TypeScript interview free →

See Cohesyve in action

Free 30-min walkthrough

See it on your role