// REF. 10 / TYPESCRIPT

TypeScript cheat sheet

The type-level toolkit: unions and narrowing, interface versus type, generics and constraints, the utility types you reach for daily, keyof and typeof and indexed access, mapped and conditional types, declaration files, and the tsconfig options that changed under you. Current to TypeScript 7.0, the native Go compiler released July 2026, with 7.1 in beta; checked against the handbook and release notes in October 2026.

Two habits: use satisfies where you used to annotate, so you keep the inferred type, and keep a never in every switch default so a new union member fails loudly.

↓ Download the printable PDF free · letter size · no email needed

Types

[string, number]
tuple; [a, b?] optional, ...T[] rest
"a" | "b"
literal union
unknown
safe any: narrow before use
never
nothing; powers exhaustiveness
x as HTMLCanvasElement
assertion, no runtime check
as const
readonly literal types, no widening
x!
non-null assertion — you promise

Interface vs type

interface A extends B {}
open: merges, extendable
type A = B & { x: 1 }
closed: any type, unions too
prop?: T
optional property
[key: string]: T
index signature
x satisfies Shape
check the shape, keep inferred type

Narrowing

typeof x === "string"
primitive guard
"swim" in animal
property guard
x instanceof Date
class guard
pet is Fish
custom predicate return type
switch (shape.kind)
discriminated union
const _x: never = shape
exhaustive default branch

Generics

function id<T>(x: T): T
generic function
<T extends Lengthwise>
constraint
<K extends keyof T>
key constrained to T's keys
<T = string>
default type parameter
interface Box<T> {}
generic interface or class

Utility types

Partial<T> / Required<T>
all optional / all required
Pick<T, K> / Omit<T, K>
keep / drop keys
Record<K, V>
object keyed by K
Exclude<U, M> / Extract
filter a union
ReturnType<F>
from a function type; Parameters too
Awaited<T>
unwrap a Promise, recursively
NoInfer<T>
block inference at this site

Type operators

keyof T
union of property names
typeof val
type of a value
T["key"]
indexed access
T extends U ? X : Y
conditional type
infer R
capture a type in the true branch
{ [K in keyof T]: T[K] }
mapped type
-readonly / -?
strip modifiers in a mapped type

Declarations

declare module "lib" {}
type a module that ships none
export function f(): T;
.d.ts signature, no body
declare const x: RegExp;
ambient value
"declaration": true
emit .d.ts from your code

Tsconfig

"strict": true
default on since 6.0
"module": "nodenext"
Node rules; esnext is the default
"moduleResolution"
bundler or nodenext — node10 gone
"noEmit": true
type-check only
noUncheckedIndexedAccess | arr[i] is T
undefined
"verbatimModuleSyntax"
type-only imports must say type
"types": []
default since 6.0; add ["node"]

TSC 7

tsc
native Go compiler since 7.0, ~10x
tsc --init
create tsconfig.json
tsc --noEmit
just type-check
tsc --watch
recompile on change
tsc --build
project references; --builders N
tsc --checkers 8
type-checker workers, default 4
TypeScript Field Manual Desk Mat

// KEEP IT UNDER YOUR KEYBOARD

TypeScript Field Manual Desk Mat

from $34 · printed to order in the USA

See the desk mat