How to use the TypeScript Cheat Sheet
- 1. Search or browseType a word like the function or task you need, or pick a section.
- 2. CopyEach snippet has its own Copy button, so you can paste it straight into your editor.
- 3. DownloadSave the whole TypeScript cheat sheet as plain text or Markdown for offline revision.
What's in it
The sheet covers TypeScript 5 features you'll meet in React, Angular and Node projects. The 34 snippets are organised into 10 sections: Basics, Types, Functions, Generics, Utility, Advanced, Narrowing, Classes, Config, Escape hatches.
Example
Search "utility" to see Partial, Required, Readonly, Pick, Omit, Record, ReturnType and Awaited together. Search "satisfies" for const cfg = { port: 3000 } satisfies Config, which checks the object against Config but keeps its precise type, unlike a plain annotation.
Tips for using it
- Turn on strict in tsconfig; many snippets assume it.
- Use the escape hatches in the last section rarely; they switch off the checks that catch bugs.
A quick look, one snippet per section
- Basics:
let id: number = 5; let name: string = "Asha"; let ok: boolean = true;(primitive annotations) - Types:
type ID = string | number;(union type) - Functions:
function greet(name: string, greeting = "Hi"): string { … }(parameters and return type) - Generics:
function first<T>(arr: T[]): T | undefined { return arr[0]; }(generic function) - Utility:
Partial<User> · Required<User> · Readonly<User>(make all optional / required / readonly) - Advanced:
type Keys = keyof User;(union of property names) - Narrowing:
if ("email" in u) { … }(in narrowing) - Classes:
class Account { constructor(private balance: number) {} }(parameter property) - Config:
"strict": true, "noUncheckedIndexedAccess": true(recommended tsconfig settings)
Search the box above for the rest of the TypeScript snippets, or download the full sheet.
Frequently asked questions
Which TypeScript version?
TypeScript 5.x; satisfies needs 4.9 or later.
Is this for Angular too?
Yes. These are core language features used in every framework.
Is the TypeScript cheat sheet free?
Yes. You can search, read and copy every snippet in the TypeScript cheat sheet without signing up. The first time you download it, we ask once for your name and WhatsApp number; after that downloads and every other Uncodemy tool open straight away.