A | B) describes a value that can be either type A or type B. An Intersection Type (A & B) combines multiple types into one, producing a type that possesses all properties of both A and B simultaneously.Master type-level programming in TypeScript with this comprehensive flashcard deck covering conditional types, mapped types, generics, and core utility types.
Preview terms and definitions before starting your study session.
A | B) describes a value that can be either type A or type B. An Intersection Type (A & B) combines multiple types into one, producing a type that possesses all properties of both A and B simultaneously.extends) Limit Generic Parametersextends keyword.function getLength<T extends { length: number }>(arg: T): number {
return arg.length;
}T must be an object type containing at least a numeric length property.keyof Type Operatorkeyof operator takes an object type and produces a string or numeric literal union of its keys.type User = { id: number; name: string };
type UserKeys = keyof User; // 'id' | 'name'T[K]) Look Up Property Typestype User = { id: number; name: string; active: boolean };
type NameType = User['name']; // string
type KeyTypes = User['id' | 'active']; // number | booleanT extends U ? X : YT is assignable to type U, the result is type X; otherwise, it evaluates to type Y.infer Keyword in Conditional Typesinfer keyword declares a type variable within the extends clause of a conditional type to extract and infer a subtype.type UnpackArray<T> = T extends (infer U)[] ? U : T;
type Num = UnpackArray<number[]>; // numbertype ToArray<T> = T extends any ? T[] : never;
type Result = ToArray<string | number>; // string[] | number[]extends clause in square brackets [ ].type NonDistributive<T> = [T] extends [any] ? T[] : never;
type Result = NonDistributive<string | number>; // (string | number)[]Explore similar study materials created by the community
Master high-frequency JLPT N2 grammar patterns, critical reading transition words, and high-yield kanji compounds to boost your exam score.
Master key networking concepts, OSI layer troubleshooting, IPv4/IPv6 subnetting calculations, critical port numbers, and Wi-Fi standards for the CompTIA Network+ N10-008 exam.
Master HSK 4 Chinese with this comprehensive flashcard deck! Dive into essential vocabulary, advanced grammar patterns like 把 and 被, common idioms, and cultural nuances to confidently elevate your conversational and reading skills.
Master essential networking protocols, topologies, cabling standards, and troubleshooting tools with this high-yield CompTIA Network+ (N10-008) flashcard deck. Perfect for IT professionals and exam candidates aiming for certification success.