From 35cf397ae3083536884304a27d9494be0a758b38 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:29:14 -0800 Subject: [PATCH] Add regression tests --- .../unionAndIntersectionInference1.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts index 7066c3e6790..d4c7d25615e 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts @@ -1,3 +1,5 @@ +// @target: es2015 + // Repro from #2264 interface Y { 'i am a very certain type': Y } @@ -70,3 +72,21 @@ declare var mbp: Man & Bear; pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man + +// Repros from #29815 + +interface ITest { + name: 'test' +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) + +const createTest = (): ITest => { + return { name: 'test' } +} + +declare function f1(x: T | U): T | U; +declare function f2(x: T & U): T & U; + +let x1: string = f1('a'); +let x2: string = f2('a');