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.
This commit is contained in:
Nathan Shively-Sanders 2017-08-24 14:04:57 -07:00
parent 2fede097f3
commit 5534899e2a

View file

@ -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 (<UnionType>indexType).types) {
const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false);