Fix crash in getAwaitedType (#52752)

This commit is contained in:
Ron Buckton
2023-02-14 11:16:12 -05:00
committed by GitHub
parent 72fb827045
commit f23dd7a7b2
5 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -39028,7 +39028,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
Debug.assert(isAwaitedTypeInstantiation(type) || getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
return type;
}
@@ -0,0 +1,7 @@
//// [awaitedTypeCrash.ts]
// https://github.com/microsoft/TypeScript/issues/51984
async function* f<T extends Promise<never>>(): AsyncGenerator<T, void, void> { }
//// [awaitedTypeCrash.js]
// https://github.com/microsoft/TypeScript/issues/51984
async function* f() { }
@@ -0,0 +1,9 @@
=== tests/cases/compiler/awaitedTypeCrash.ts ===
// https://github.com/microsoft/TypeScript/issues/51984
async function* f<T extends Promise<never>>(): AsyncGenerator<T, void, void> { }
>f : Symbol(f, Decl(awaitedTypeCrash.ts, 0, 0))
>T : Symbol(T, Decl(awaitedTypeCrash.ts, 1, 18))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
>AsyncGenerator : Symbol(AsyncGenerator, Decl(lib.es2018.asyncgenerator.d.ts, --, --))
>T : Symbol(T, Decl(awaitedTypeCrash.ts, 1, 18))
@@ -0,0 +1,5 @@
=== tests/cases/compiler/awaitedTypeCrash.ts ===
// https://github.com/microsoft/TypeScript/issues/51984
async function* f<T extends Promise<never>>(): AsyncGenerator<T, void, void> { }
>f : <T extends Promise<never>>() => AsyncGenerator<T, void, void>
+4
View File
@@ -0,0 +1,4 @@
// @target: esnext
// https://github.com/microsoft/TypeScript/issues/51984
async function* f<T extends Promise<never>>(): AsyncGenerator<T, void, void> { }