mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Add Exclude, Extract, NonNullable, ReturnType, and InstanceType types
This commit is contained in:
parent
6dd88b39d5
commit
2aba29fc32
25
src/lib/es5.d.ts
vendored
25
src/lib/es5.d.ts
vendored
@ -1338,6 +1338,31 @@ type Record<K extends string, T> = {
|
||||
[P in K]: T;
|
||||
};
|
||||
|
||||
/**
|
||||
* Exclude from T those types that are assignable to U
|
||||
*/
|
||||
type Exclude<T, U> = T extends U ? never : T;
|
||||
|
||||
/**
|
||||
* Extract from T those types that are assignable to U
|
||||
*/
|
||||
type Extract<T, U> = T extends U ? T : never;
|
||||
|
||||
/**
|
||||
* Exclude null and undefined from T
|
||||
*/
|
||||
type NonNullable<T> = T extends null | undefined ? never : T;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a function type
|
||||
*/
|
||||
type ReturnType<T extends (...args: any[]) => any> = T extends (...args: any[]) => infer R ? R : any;
|
||||
|
||||
/**
|
||||
* Obtain the return type of a constructor function type
|
||||
*/
|
||||
type InstanceType<T extends new (...args: any[]) => any> = T extends new (...args: any[]) => infer R ? R : any;
|
||||
|
||||
/**
|
||||
* Marker for contextual 'this' type
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user