TypeScript-Handbook
TypeScript-Handbook copied to clipboard
Fix description of Exclude and Extract types
The previous description was:
Constructs a type by excluding/extracting from
Tall properties that are assignable toU.
This sounds to me like Exclude and Extract would do this:
interface Person {
id: number;
name: string;
}
type NumbersOnly = Extract<Person, number>; // { id: number }
type NoNumbers = Exclude<Person, number>; // { name: string }
I think "Constructs a type by excluding/extracting from T all types that are assignable to U," more clearly describes removing types from the union, rather than affecting its properties.