Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 678 Bytes

File metadata and controls

43 lines (31 loc) · 678 Bytes

typelab / utils / ExtractPromise

type ExtractPromise<T> = T extends Promise<infer U> ? U : never;

Extract the value type from a Promise type.

Type Parameters

Type Parameter Description

T extends Promise<Any>

The input type which should be a Promise.

Returns

The type of the return value in the Promise, or never if T is not a Promise.

Example

type Valid = ExtractPromise<Promise<number>>; // number
type Invalid = ExtractPromise<number>> // never