flâneur

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