Define Rest<T, K> as Pick<T, Exclude<keyof T, K>> to ensure it is homomorphic

This commit is contained in:
Anders Hejlsberg 2018-11-01 16:48:12 -07:00
parent b0a5337604
commit 0b194a2b34

12
src/lib/es5.d.ts vendored
View File

@ -1416,13 +1416,6 @@ type Pick<T, K extends keyof T> = {
[P in K]: T[P];
};
/**
* From T, omit a set of properties whose keys are in the union K
*/
type Rest<T, K extends keyof T> = {
[P in Exclude<keyof T, K>]: T[P];
};
/**
* Construct a type with a set of properties K of type T
*/
@ -1445,6 +1438,11 @@ type Extract<T, U> = T extends U ? T : never;
*/
type NonNullable<T> = T extends null | undefined ? never : T;
/**
* From T, pick all properties except those in the union K
*/
type Rest<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
/**
* Obtain the parameters of a function type in a tuple
*/