From cf479fc384bad6f171927a4334954331d076003c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 20 Jan 2019 08:21:41 -0800 Subject: [PATCH] Add regression test for #29168 --- .../compiler/contextualTypeShouldBeLiteral.ts | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/cases/compiler/contextualTypeShouldBeLiteral.ts b/tests/cases/compiler/contextualTypeShouldBeLiteral.ts index 1012c567a71..5da49215f5f 100644 --- a/tests/cases/compiler/contextualTypeShouldBeLiteral.ts +++ b/tests/cases/compiler/contextualTypeShouldBeLiteral.ts @@ -93,4 +93,30 @@ let xyz: LikeA | LikeB = { } }; -xyz; \ No newline at end of file +xyz; + +// Repro from #29168 + +interface TestObject { + type?: 'object'; + items: { + [k: string]: TestGeneric; + }; +} + +interface TestString { + type: 'string'; +} + +type TestGeneric = (TestString | TestObject) & { [k: string]: any; }; + +const test: TestGeneric = { + items: { + hello: { type: 'string' }, + world: { + items: { + nested: { type: 'string' } + } + } + } +};