From f929a25407900ff2b353ad532853290122ca03b1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 15 Aug 2019 10:02:32 -0700 Subject: [PATCH] Add regression test --- .../typeInference/unionTypeInference.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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); + } +}