Skip to main content
Ganesh Joshi
Back to Cheatsheets

TypeScript quick reference

Updated 2026-02-14

TypeScript types, interfaces, utility types, and common patterns. Primitives, unions, generics.

Primitives and basics

string, number, boolean, null, undefined, symbol, bigint. let x: string = 'hi'; const arr: number[] = [1,2]; const tuple: [string, number] = ['a', 1]. Optional: name?: string. Readonly: readonly string[].

Unions, intersections, type alias

type Id = string | number; type A = { a: number }; type B = { b: string }; type C = A & B. type Foo = { name: string; age?: number };. interface Foo { name: string } (extends, optional, readonly).

Generics

function id<T>(x: T): T { return x; }. type Box<T> = { value: T };. class Queue<T> { }. Constraints: <T extends { id: number }>. Default: <T = string>.

Utility types

Partial<T>, Required<T>, Readonly<T>. Pick<T, 'a'|'b'>, Omit<T, 'a'>. Record<K, V>. Exclude<T, U>, Extract<T, U>. NonNullable<T>. ReturnType<F>, Parameters<F>. Awaited<T> for Promise.

Other

as const for literal types. keyof T, typeof obj. Index signature: [key: string]: number. Mapped type: { [K in keyof T]: T[K] }. Conditional: T extends U ? X : Y.

TypeScript quick reference | Cheatsheet | Ganesh Joshi