diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts b/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts index 4d9a3eae21e..6203da5e989 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts @@ -1,4 +1,5 @@ // @strict: true +// @target: esnext declare const b: boolean; declare const s: string; @@ -51,3 +52,20 @@ foo(x); declare function bar(x: T, y: string | T): T; const y = bar(1, 2); + +// Repro from #32752 + +const containsPromises: unique symbol = Symbol(); + +type DeepPromised = + { [containsPromises]?: true } & + { [TKey in keyof T]: T[TKey] | DeepPromised | Promise> }; + +async function fun(deepPromised: DeepPromised) { + const deepPromisedWithIndexer: DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised; + for (const value of Object.values(deepPromisedWithIndexer)) { + const awaitedValue = await value; + if (awaitedValue) + await fun(awaitedValue); + } +}