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:
parent
2fede097f3
commit
5534899e2a
1 changed files with 1 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue