Topics

Jump to a topic.

Search questions

Find a question by title, tag, or summary.

TypeScript

TypeScript's type system and compiler: how types are checked, inferred, and erased. Most frontend and Node.js codebases are TypeScript now, and interviews probe whether you can reason about types rather than just annotate.
8
chapters
47
questions
14
core
  1. 01Type system basics6 questions
    How TypeScript decides whether one type fits another, and the core building blocks: structural typing, any / unknown / never, literal types, object and function types.
    • What is the difference between type and interface?Coming soon
    • What is structural typing, and how does it differ from nominal typing?Coming soon
    • What is the difference between any, unknown, and never?Coming soon
    • What are literal types, and what does as const do?Coming soon
    • Why does TypeScript report an error on an object literal but not on a variable with the same shape?Coming soon
    • How do function types, overloads, and the void return type work?Coming soon
    Open chapter page
  2. 02Inference and narrowing6 questions
    How the compiler infers types and narrows them through control flow: type guards, discriminated unions, satisfies, and assertions.
    • How does TypeScript infer types, and when should you annotate explicitly?Coming soon
    • How does narrowing work, and what built-in checks narrow a type?Coming soon
    • How do you write a user-defined type guard or assertion function?Coming soon
    • What is a discriminated union, and how do you check it exhaustively?Coming soon
    • What does satisfies do, and how is it different from a type annotation?Coming soon
    • What do as, !, and !: actually do, and when are they safe?Coming soon
    Open chapter page
  3. 03Generics5 questions
    Parameterised types and functions: constraints, defaults, inference of type arguments, variance, and the keyof / typeof / indexed-access operators.
    • What are generics, and how do extends constraints work?Coming soon
    • How are generic type arguments inferred, and when does inference go wrong?Coming soon
    • What are covariance and contravariance, and what do in and out do?Coming soon
    • What do keyof, typeof, and indexed access types do?Coming soon
    • What are const type parameters and NoInfer?Coming soon
    Open chapter page
  4. 04Type-level programming6 questions
    Computing types from types: conditional types and infer, mapped types, template literal types, recursive types, and the built-in utility types.
    • How do conditional types work, and what is distribution?Coming soon
    • What does infer do? Implement ReturnType and Awaited.Coming soon
    • How do mapped types work, including key remapping and + / - modifiers?Coming soon
    • What are template literal types, and what are they used for?Coming soon
    • Which built-in utility types do you use, and how would you implement them?Coming soon
    • How do you write a recursive type such as DeepPartial, and what are the limits?Coming soon
    Open chapter page
  5. 05Classes, enums, and runtime output6 questions
    TypeScript features that are more than types: classes, enums, namespaces, and decorators, and which of them emit JavaScript.
    • Should you use enums or union types?Coming soon
    • How do TypeScript classes differ from JavaScript classes: modifiers, parameter properties, #private?Coming soon
    • When do you use abstract classes versus implements an interface?Coming soon
    • What is declaration merging, and are namespaces still used?Coming soon
    • How do decorators work in TypeScript?Coming soon
    • Which TypeScript syntax has runtime output, and why does erasableSyntaxOnly exist?Coming soon
    Open chapter page
  6. 06Modules and declaration files6 questions
    How TypeScript resolves and types modules: moduleResolution, ESM/CJS interop, .d.ts files, declare, and augmentation.
    • What do import type, isolatedModules, and verbatimModuleSyntax do?Coming soon
    • How does moduleResolution work, and when do you use bundler or nodenext?Coming soon
    • Why does importing a CommonJS module sometimes fail, and what does esModuleInterop do?Coming soon
    • What is a .d.ts file, and how do you write one for an untyped library?Coming soon
    • How do you augment a module or add a global type?Coming soon
    • How can you type-check JavaScript with TypeScript?Coming soon
    Open chapter page
  7. 07tsconfig and strictness6 questions
    What tsconfig.json controls: strictness flags, targets and libs, path mapping, and project references.
    • What does strict enable, and why is strictNullChecks the important one?Coming soon
    • Which flags beyond strict do you turn on, such as noUncheckedIndexedAccess?Coming soon
    • What is the difference between target, lib, and module?Coming soon
    • How do paths, baseUrl, and extends work?Coming soon
    • What are project references, and how do composite and incremental help?Coming soon
    • What do skipLibCheck, declaration, and sourceMap do?Coming soon
    Open chapter page
  8. 08The compiler6 questions
    What tsc does: checking versus emitting, type erasure, how other tools strip types, and the native compiler port.
    • What does TypeScript erase at compile time, and what does that mean for runtime checks?Coming soon
    • What is the difference between type checking and transpiling, and why do bundlers skip checking?Coming soon
    • How does Node.js run TypeScript files directly?Coming soon
    • What are the stages of the TypeScript compiler?Coming soon
    • What is the native (Go) port of the TypeScript compiler?Coming soon
    • Is TypeScript's type system sound? Where does it not catch errors?Coming soon
    Open chapter page