Master Typescript Generics Patterns And Constraints with 241 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.
function identity<T>(x: T): T { return x; }
function len<T extends { length: number }>(x: T) { return x.length; }
Restricts T to string-assignable types — required when you use string-specific operations or template literal types.
identity<number>(42) — usually inferred.
function pick<T, K extends keyof T = keyof T>(...) — K defaults to keyof T.
type Elem<T> = T extends (infer U)[] ? U : never;
type R = ReturnType<typeof fn>;
type P = Parameters<typeof fn>;
Partial<T>
Required<T>
Readonly<T>
Pick<User, 'id' | 'email'>
Flashcards
Flip to reveal
Focus Mode
Spaced repetition
Multiple Choice
Test your knowledge
Type Answer
Active recall
Learn Mode
Multi-round mastery
Match Game
Memory challenge