Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#46413 fix(es‑abstract): Correct `PromiseRe…
Browse files Browse the repository at this point in the history
…solve` type definition by @ExE-Boss
  • Loading branch information
ExE-Boss committed Jul 28, 2020
1 parent 4601622 commit 6615068
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/es-abstract/2018/PromiseResolve.d.ts
Expand Up @@ -4,9 +4,9 @@ type PromiseConstructorLikeReturnType<C extends PromiseConstructorLike, T> = C e
? R
: PromiseLike<T>;

declare function PromiseResolve<T>(C: PromiseConstructor, x: T): Promise<T>;
declare function PromiseResolve<T>(C: PromiseConstructor, x: T | PromiseLike<T>): Promise<T>;
declare function PromiseResolve<C extends PromiseConstructorLike, T>(
C: C,
x: T,
x: T | PromiseLike<T>,
): PromiseConstructorLikeReturnType<C, T>;
export = PromiseResolve;
5 changes: 5 additions & 0 deletions types/es-abstract/test/es2018.test.ts
Expand Up @@ -8,6 +8,11 @@ interface FakePromise<T> extends PromiseLike<T> {
doStuff(): void;
}

function testGeneric<T, TReturn>({ done, value }: IteratorResult<T | PromiseLike<T>, TReturn | PromiseLike<TReturn>>) {
// $ExpectType Promise<T | TReturn>
ES2018.PromiseResolve(Promise, value);
}

// $ExpectType FakePromise<unknown>
ES2018.PromiseResolve(FakePromise, any);

Expand Down

0 comments on commit 6615068

Please sign in to comment.