type-fest
Advanced tools
Comparing version 0.15.1 to 0.16.0
{ | ||
"name": "type-fest", | ||
"version": "0.15.1", | ||
"version": "0.16.0", | ||
"description": "A collection of essential TypeScript types", | ||
@@ -5,0 +5,0 @@ "license": "(MIT OR CC0-1.0)", |
/** | ||
Returns the type that is wrapped inside a `Promise` type. | ||
If the type is a nested Promise, it is unwrapped recursively until a non-Promise type is obtained. | ||
If the type is not a `Promise`, the type itself is returned. | ||
@@ -18,4 +19,10 @@ | ||
let syncData: SyncData = getSyncData(); | ||
// Here's an example that shows how this type reacts to recursive Promise types. | ||
type RecursiveAsyncData = Promise<Promise<string> >; | ||
let recursiveAsyncData: PromiseValue<RecursiveAsyncData> = Promise.resolve(Promise.resolve('ABC')); | ||
``` | ||
*/ | ||
export type PromiseValue<PromiseType, Otherwise = PromiseType> = PromiseType extends Promise<infer Value> ? Value : Otherwise; | ||
export type PromiseValue<PromiseType, Otherwise = PromiseType> = PromiseType extends Promise<infer Value> | ||
? { 0: PromiseValue<Value>; 1: Value }[PromiseType extends Promise<unknown> ? 0 : 1] | ||
: Otherwise; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91467
1934