Loading topic
keyof, which produces the union of an object type's property names, and indexed access, written T[K], which looks up the type of one property.2 min read<T>, and type aliases. You should also be comfortable reading keyof, which produces the union of an object type's property names.2 min read[K in keyof T], and generic type aliases. You should also know the difference between T[K] (an indexed access type) and keyof T. If any of these are new, review them first.2 min readkeyof, indexed access types such as T[K], and the basic mapped type syntax { [K in keyof T]: ... }. The examples assume strict is enabled in tsconfig.json.2 min readT extends U ? X : Y. If T is assignable to U, the result is X. Otherwise, the result is Y.2 min readT extends U ? X : Y), generics with type parameters, and union types. You should also be comfortable reading never and unknown.2 min readT extends U ? X : Y), generics with constraints, and the basic function and tuple types. You should also be comfortable with Promise and rest parameters.2 min readPartial, Pick, Exclude, and ReturnType, from the mapped and conditional type tools. You should already know object types, unions, generics with constraints, and type aliases. Each helper here uses keyof, indexed access2 min readextends constraints, and mapped types with keyof. You should also be comfortable with as clauses in mapped types, since the examples use them.2 min read[K in keyof T], use indexed access types such as T[K], and write conditional types with extends ? :. You should also know template literal types, such as ` get${string} `.2 min readextends, and the infer keyword. You should also be comfortable with generics and with the keyof operator. Recursive types apply these tools to a value that contains more values of the same shape, such as nested objects or wrapp2 min readextends, understand what a naked type parameter is, and have used infer at least once. You should also be comfortable with union types.2 min read[K in keyof T]), conditional types (T extends U ? X : Y), and template literal types. Key remapping with as requires TypeScript 4.1 or later.1 min read