Shiki
shiki.style · 359 words · saved by 3 readers
A beautiful yet powerful syntax highlighter
// Using 'typeof' to infer types const person = { name: "Alice", age: 30 }; type PersonType = typeof person; // { name: string; age: number } // 'satisfies' to ensure a type matches but allows more specific types type Animal = { name: string }; const dog = { name: "Buddy", breed: "Golden Retriever" } satisfies Animal; // Generics with 'extends' and default values function identity<T extends number | string = string>(arg: T): T { return arg; } let str = identity(); // Default type is string let num = identity(42); // T inferred as number // 'extends' with interface and class interface…
saved by
related reading
- TypeScript: Documentation - Genericstypescriptlang.org
- Ship types, not docsshiptypes.com
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- TypeScript: Documentation - The Basicstypescriptlang.org
- TypeScript: Documentation - Object Typestypescriptlang.org
- Intro | Zodzod.dev
- TypeScript: Documentation - More on Functionstypescriptlang.org
- Typescript utility types that you must know - DEV Communitydev.to
- Everything is Fertilenickcammarata.com
- Basic TypeScriptweb.mit.edu
- TypeScript: Documentation - TypeScript 3.7typescriptlang.org
- Reading 2: Basic TypeScriptweb.mit.edu