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
- 63
- questions
- 14
- core
- 762
- flashcards
- 63 not yet reviewed
- Last verified October 2026
01Type system basics7 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
typeandinterface? - What is structural typing, and how does it differ from nominal typing?
- What is the difference between
any,unknown, andnever? - What are literal types, and what does
as constdo? - Why does TypeScript report an error on an object literal but not on a variable with the same shape?
- How do function types, overloads, and the
voidreturn type work? - How do you type iterators and generators in TypeScript?
- What is the difference between
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?
- How does narrowing work, and what built-in checks narrow a type?
- How do you write a user-defined type guard or assertion function?
- What is a discriminated union, and how do you check it exhaustively?
- What does
satisfiesdo, and how is it different from a type annotation? - What do
as,!, and!:actually do, and when are they safe?
03Generics5 questions
Parameterised types and functions: constraints, defaults, inference of type arguments, variance, and thekeyof/typeof/ indexed-access operators.- What are generics, and how do
extendsconstraints work? - How are generic type arguments inferred, and when does inference go wrong?
- What are covariance and contravariance, and what do
inandoutdo? - What do
keyof,typeof, and indexed access types do? - What are
consttype parameters andNoInfer?
- What are generics, and how do
04Type-level programming8 questions
Computing types from types: conditional types andinfer, mapped types, template literal types, recursive types, and the built-in utility types.- How do conditional types work, and what is distribution?
- What does
inferdo? ImplementReturnTypeandAwaited. - How do mapped types work, including key remapping and
+/-modifiers? - What are template literal types, and what are they used for?
- Which built-in utility types do you use, and how would you implement them?
- How do you write a recursive type such as
DeepPartial, and what are the limits? - What do
InstanceType,ConstructorParameters, and thethisutility types do? - How do variadic tuple types work, and how do you do arithmetic with tuples at the type level?
05Classes, enums, and runtime output9 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?
- How do TypeScript classes differ from JavaScript classes: modifiers, parameter properties,
#private? - How do
useDefineForClassFields,declarefields, andstaticblocks change class fields? - When do you use
abstractclasses versusimplementsan interface? - How do you type a mixin in TypeScript?
- What is declaration merging, and are namespaces still used?
- How do decorators work in TypeScript?
- How do decorator metadata and
accessorfields work, and what didemitDecoratorMetadatagive DI frameworks? - Which TypeScript syntax has runtime output, and why does
erasableSyntaxOnlyexist?
06Modules and declaration files10 questions
How TypeScript resolves and types modules:moduleResolution, ESM/CJS interop,.d.tsfiles,declare, and augmentation.- What do
import type,isolatedModules, andverbatimModuleSyntaxdo? - How does
moduleResolutionwork, and when do you usebundlerornodenext? - Why does importing a CommonJS module sometimes fail, and what does
esModuleInteropdo? - How do you ship types for a package that publishes both ESM and CommonJS?
- What is a
.d.tsfile, and how do you write one for an untyped library? - How do you write a declaration file for a global, UMD, or function-exporting library?
- How do you augment a module or add a global type?
- How do you type imports of CSS, SVG, and other non-JS files?
- How can you type-check JavaScript with TypeScript?
- How do you type callbacks, overloads,
this, and constrained generics in JSDoc?
- What do
07tsconfig and strictness9 questions
Whattsconfig.jsoncontrols: strictness flags, targets and libs, path mapping, and project references.- What does
strictenable, and why isstrictNullChecksthe important one? - Which flags beyond
strictdo you turn on, such asnoUncheckedIndexedAccess? - What do
noUnusedLocals,noUnusedParameters, andnoFallthroughCasesInSwitchcatch, and when do you leave them to a linter? - What is the difference between
target,lib, andmodule? - How do
paths,baseUrl, andextendswork? - What do
types,typeRoots,rootDir, andoutDirdefault to, and what changed in TypeScript 6? - What are project references, and how do
compositeandincrementalhelp? - What do
skipLibCheck,declaration, andsourceMapdo? - How do you migrate a project from TypeScript 6 to TypeScript 7?
- What does
08The compiler9 questions
Whattscdoes: 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?
- What is the difference between type checking and transpiling, and why do bundlers skip checking?
- Which TypeScript features break under single-file transpilers, and what does
isolatedDeclarationsadd? - How does Node.js run TypeScript files directly?
- What are the stages of the TypeScript compiler?
- How does the checker relate and cache types, and how do editors talk to
tsserver? - What is the native (Go) port of the TypeScript compiler?
- How do tools built on the TypeScript compiler API move to the native compiler?
- Is TypeScript's type system sound? Where does it not catch errors?