Fix await for inherited promise

This commit is contained in:
Ron Buckton 2016-12-07 17:17:17 -08:00
parent b0bbbcbe07
commit 8dcbea9675
5 changed files with 50 additions and 1 deletions

View File

@ -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;
}

View 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;
}

View File

@ -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))
}

View 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
}

View File

@ -0,0 +1,7 @@
// @target: es2017
// @strictNullChecks: true
interface A extends Promise<string> {}
declare var a: A;
async function f() {
await a;
}