Skip to content

Commit cb472eb

Browse files
committed
move code around to consolidate checks in one place
1 parent 365587f commit cb472eb

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7494,27 +7494,25 @@ module ts {
74947494

74957495
if (e.kind === SyntaxKind.Identifier) {
74967496
// unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work.
7497-
// instead pick symbol that correspond of enum declaration and later try to fetch member from the symbol
7497+
// instead pick current enum type and later try to fetch member from the type
74987498
enumType = currentType;
74997499
propertyName = (<Identifier>e).text;
75007500
}
7501-
else if (e.kind === SyntaxKind.IndexedAccess) {
7502-
if ((<IndexedAccess>e).index.kind !== SyntaxKind.StringLiteral) {
7503-
return undefined;
7501+
else {
7502+
if (e.kind === SyntaxKind.IndexedAccess) {
7503+
if ((<IndexedAccess>e).index.kind !== SyntaxKind.StringLiteral) {
7504+
return undefined;
7505+
}
7506+
var enumType = getTypeOfNode((<IndexedAccess>e).object);
7507+
propertyName = (<LiteralExpression>(<IndexedAccess>e).index).text;
75047508
}
7505-
var enumType = getTypeOfNode((<IndexedAccess>e).object);
7506-
if (enumType !== currentType) {
7507-
return undefined;
7509+
else {
7510+
var enumType = getTypeOfNode((<PropertyAccess>e).left);
7511+
propertyName = (<PropertyAccess>e).right.text;
75087512
}
7509-
propertyName = (<LiteralExpression>(<IndexedAccess>e).index).text;
7510-
}
7511-
else {
7512-
// left part in PropertyAccess should be resolved to the symbol of enum that declared 'member'
7513-
var enumType = getTypeOfNode((<PropertyAccess>e).left);
75147513
if (enumType !== currentType) {
75157514
return undefined;
75167515
}
7517-
propertyName = (<PropertyAccess>e).right.text;
75187516
}
75197517

75207518
if (propertyName === undefined) {

0 commit comments

Comments
 (0)