Interview Prep

TypeScript interview questions and how to answer them

TypeScript questions go deeper than "what is a type." Expect generics, narrowing, conditional types, and how TypeScript interacts with your build. These reflect what teams actually care about in TypeScript interviews.

PrepVault keeps your study guides and prep notes organized by role. Free to start.

TypeScript interview questions and how to answer them

  • What TypeScript error should this annotated function produce?

    return type mismatch. number not assignable to string. contract or implementation fix

  • How does this generic ApiResponse interface preserve payload type?

    T used for data. response-specific payload. reusable API wrapper

  • Why does this union type code produce an error?

    number case possible. method not safe for union. narrow with typeof

  • How do you design a generic Result<T, E> type in TypeScript that supports monadic chaining (map, flatMap, mapError) with full type inference at each step, and what are the performance implications of deeply chaining conditional types during type checking?

    Ok/Err discriminated union enables type narrowing inside map/flatMap. flatMap widens the error union to E | E2 preserving error type history. deep conditional types cause quadratic compile-time growth. discriminated union dispatch scales linearly unlike nested conditional types

  • How do TypeScript 5 decorators differ from the legacy experimentalDecorators implementation in terms of what the decorator function receives and when it runs?

    TC39 stage-3 decorators pass (value, context) not (target, key, descriptor). context.addInitializer replaces constructor-wrapping class decorators. context.metadata replaces reflect-metadata for per-class data. the two systems cannot coexist in the same file

  • What is a type annotation in TypeScript?

    explicit expected type. parameters and returns. use at boundaries

  • What are mapped types in TypeScript?

    iterate over keys. transform property types. basis for utilities

  • What is the as keyword used for in TypeScript and what are the risks?

    compile-time only, no runtime effect. bypasses type checking - you take responsibility. common use: DOM APIs, JSON parsing, narrowing escape hatches. double assertion (as unknown as T) is a red flag

  • What type safety does this generic Store class provide?

    instance-specific T. add accepts T. all returns T[]

  • What type does this Pick utility create?

    id and name only. types reused from User. compile-time subset

Common mistakes

  • Treating it as JavaScript with types and nothing more
  • Struggling with generics and narrowing
  • Not knowing what TypeScript does at runtime

What interviewers weigh

  • Depth on the type system and generics
  • When you would reach for which type
  • How TypeScript fits into the build

More that helps

Start free with PrepVault