TypeScript Functions and Narrowing
Function typing, overloads, control-flow narrowing, and async typing.
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Functions and Parameters
## Narrowing and Control Flow
type State = "idle" | "loading" | "success";
function render(state: State) {
switch (state) {
case "idle":
return "Idle";
case "loading":
return "Loading";
case "success":
return "Done";
default: {
const _exhaustive: never = state;
return _exhaustive;
}
}
}# Catch unhandled union members.
## Async and Promise Types
More in TypeScript
TypeScript Utility Types and Recipes
Built-in utility types and practical application patterns.
TypeScript tsconfig and Tooling
tsconfig.json patterns, diagnostics, and project references.
TypeScript Classes and Modules
Classes, access modifiers, inheritance, modules, and validation boundaries.
TypeScript Types and Generics
Advanced type operators, mapped types, conditional types, and utility types.
TypeScript Cheat Sheet
Core TypeScript syntax, typing patterns, and compiler commands.