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
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
typeandinterface?Coming soon - What is structural typing, and how does it differ from nominal typing?Coming soon
- What is the difference between
any,unknown, andnever?Coming soon - What are literal types, and what does
as constdo?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
voidreturn type work?Coming soon
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
satisfiesdo, and how is it different from a type annotation?Coming soon - What do
as,!, and!:actually do, and when are they safe?Coming soon
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?Coming soon - How are generic type arguments inferred, and when does inference go wrong?Coming soon
- What are covariance and contravariance, and what do
inandoutdo?Coming soon - What do
keyof,typeof, and indexed access types do?Coming soon - What are
consttype parameters andNoInfer?Coming soon
04Type-level programming6 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?Coming soon
- What does
inferdo? ImplementReturnTypeandAwaited.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
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
abstractclasses versusimplementsan 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
erasableSyntaxOnlyexist?Coming soon
06Modules and declaration files6 questions
How TypeScript resolves and types modules:moduleResolution, ESM/CJS interop,.d.tsfiles,declare, and augmentation.- What do
import type,isolatedModules, andverbatimModuleSyntaxdo?Coming soon - How does
moduleResolutionwork, and when do you usebundlerornodenext?Coming soon - Why does importing a CommonJS module sometimes fail, and what does
esModuleInteropdo?Coming soon - What is a
.d.tsfile, 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
07tsconfig and strictness6 questions
Whattsconfig.jsoncontrols: strictness flags, targets and libs, path mapping, and project references.- What does
strictenable, and why isstrictNullChecksthe important one?Coming soon - Which flags beyond
strictdo you turn on, such asnoUncheckedIndexedAccess?Coming soon - What is the difference between
target,lib, andmodule?Coming soon - How do
paths,baseUrl, andextendswork?Coming soon - What are project references, and how do
compositeandincrementalhelp?Coming soon - What do
skipLibCheck,declaration, andsourceMapdo?Coming soon
08The compiler6 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?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