TypeScript Cheat Sheet
TypeScript types, interfaces, generics, and advanced type patterns.
3 PagesIntermediateMay 8, 2026
Basic Types
Annotate variables with primitive types.
typescript
let id: number = 5;let name: string = "SkillVeris";let active: boolean = true;let tags: string[] = ["a", "b"];let tuple: [string, number] = ["age", 30];
Interfaces
Define the shape of an object.
typescript
interface User { id: number; name: string; email?: string; // optional readonly createdAt: Date;}function greet(u: User): string { return `Hello, ${u.name}`;}
Generics
Write reusable, type-safe functions.
typescript
function identity<T>(value: T): T { return value;}function firstItem<T>(arr: T[]): T | undefined { return arr[0];}
Utility Types
Built-in type transformations.
- Partial<T>- All properties optional
- Required<T>- All properties required
- Pick<T,K>- Subset of keys
- Omit<T,K>- Exclude keys
- Record<K,V>- Object type with keys K, values V
Pro Tip
Enable "strict": true in tsconfig.json from day one — retrofitting strict mode later is far more painful.
Was this cheat sheet helpful?
Explore Topics
#TypeScript#TypeScriptCheatSheet#Programming#Intermediate#BasicTypes#Interfaces#Generics#UtilityTypes#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance