MSNCodeSNIPPETS← msncode.dev
snippets/typescript

Type Async Function Return

Properly type the return of an async function

typescripttypescriptasynctype
TYPESCRIPT
async function fetchUser(id: string): Promise<User> { /* ... */ }

More typescript snippets

Omit Keys from Object Type

Create a type with specific keys removed

Make All Fields Optional

Make every property of a type optional

Pick Specific Keys from Type

Create a type with only selected keys

Readonly Array

Make an array immutable - no push, pop, or splice