From 5534899e2a0bd6d9e27177d7ab1fd94f06717082 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 24 Aug 2017 14:04:57 -0700 Subject: [PATCH] Allow string enums in element access Previously literal union types were disallowed to improve errors by printing `boolean` instead of `true | false`. But string enums are literal union types that should be allowed, so now only booleans are disallowed. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4a07f349c9..08770fc8d8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7688,7 +7688,7 @@ namespace ts { } // In the following we resolve T[K] to the type of the property in T selected by K. const apparentObjectType = getApparentType(objectType); - if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Primitive)) { + if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Boolean)) { const propTypes: Type[] = []; for (const t of (indexType).types) { const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false);