mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Fix await for inherited promise
This commit is contained in:
parent
b0bbbcbe07
commit
8dcbea9675
@ -16207,7 +16207,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull);
|
||||
if (isTypeAny(onfulfilledParameterType)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
11
tests/baselines/reference/awaitInheritedPromise_es2017.js
Normal file
11
tests/baselines/reference/awaitInheritedPromise_es2017.js
Normal file
@ -0,0 +1,11 @@
|
||||
//// [awaitInheritedPromise_es2017.ts]
|
||||
interface A extends Promise<string> {}
|
||||
declare var a: A;
|
||||
async function f() {
|
||||
await a;
|
||||
}
|
||||
|
||||
//// [awaitInheritedPromise_es2017.js]
|
||||
async function f() {
|
||||
await a;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
|
||||
interface A extends Promise<string> {}
|
||||
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
declare var a: A;
|
||||
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
|
||||
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
|
||||
|
||||
async function f() {
|
||||
>f : Symbol(f, Decl(awaitInheritedPromise_es2017.ts, 1, 17))
|
||||
|
||||
await a;
|
||||
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
|
||||
}
|
||||
16
tests/baselines/reference/awaitInheritedPromise_es2017.types
Normal file
16
tests/baselines/reference/awaitInheritedPromise_es2017.types
Normal file
@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
|
||||
interface A extends Promise<string> {}
|
||||
>A : A
|
||||
>Promise : Promise<T>
|
||||
|
||||
declare var a: A;
|
||||
>a : A
|
||||
>A : A
|
||||
|
||||
async function f() {
|
||||
>f : () => Promise<void>
|
||||
|
||||
await a;
|
||||
>await a : string
|
||||
>a : A
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
// @target: es2017
|
||||
// @strictNullChecks: true
|
||||
interface A extends Promise<string> {}
|
||||
declare var a: A;
|
||||
async function f() {
|
||||
await a;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user