@@ -5787,8 +5787,8 @@ module ts {
57875787
57885788 // See if we can index as a property.
57895789 if (node.argumentExpression) {
5790- if (node.argumentExpression.kind === SyntaxKind.StringLiteral || node.argumentExpression.kind === SyntaxKind.NumericLiteral) {
5791- var name = (<LiteralExpression>node.argumentExpression).text;
5790+ var name = getPropertyNameForIndexedAccess( node.argumentExpression);
5791+ if ( name !== undefined) {
57925792 var prop = getPropertyOfType(objectType, name);
57935793 if (prop) {
57945794 getNodeLinks(node).resolvedSymbol = prop;
@@ -5832,6 +5832,36 @@ module ts {
58325832 return unknownType;
58335833 }
58345834
5835+ /**
5836+ * If indexArgumentExpression is a string literal or number literal, returns its text.
5837+ * If indexArgumentExpression is a well known symbol, returns the property name corresponding
5838+ * to this symbol.
5839+ * Otherwise, returns undefined.
5840+ */
5841+ function getPropertyNameForIndexedAccess(indexArgumentExpression: Expression) {
5842+ if (indexArgumentExpression.kind === SyntaxKind.StringLiteral || indexArgumentExpression.kind === SyntaxKind.NumericLiteral) {
5843+ return (<LiteralExpression>indexArgumentExpression).text;
5844+ }
5845+ if (isWellKnownSymbolSyntactically(indexArgumentExpression)) {
5846+ var leftHandSide = (<PropertyAccessExpression>indexArgumentExpression).expression;
5847+ Debug.assert((<Identifier>leftHandSide).text === "Symbol");
5848+ // The name is Symbol.<someName>, so make sure Symbol actually resolves to the
5849+ // global Symbol object
5850+ var leftHandSideSymbol = resolveName(indexArgumentExpression, (<Identifier>leftHandSide).text,
5851+ SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
5852+ if (leftHandSideSymbol === globalESSymbolConstructorSymbol) {
5853+ // Make sure the property type is the primitive symbol type
5854+ var rightHandSideName = (<Identifier>(<PropertyAccessExpression>indexArgumentExpression).name).text;
5855+ var esSymbolConstructorPropertyType = getTypeOfPropertyOfType(globalESSymbolConstructorType, rightHandSideName);
5856+ if (esSymbolConstructorPropertyType && esSymbolConstructorPropertyType.flags & TypeFlags.ESSymbol) {
5857+ return getPropertyNameForKnownSymbolName(rightHandSideName);
5858+ }
5859+ }
5860+ }
5861+
5862+ return undefined;
5863+ }
5864+
58355865 function resolveUntypedCall(node: CallLikeExpression): Signature {
58365866 if (node.kind === SyntaxKind.TaggedTemplateExpression) {
58375867 checkExpression((<TaggedTemplateExpression>node).template);
@@ -10334,7 +10364,7 @@ module ts {
1033410364 globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
1033510365 globalESSymbolType = getGlobalType("Symbol");
1033610366 globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol");
10337- globalESSymbolConstructorType = getTypeOfGlobalSymbol (globalESSymbolConstructorSymbol, /*arity*/ 0 );
10367+ globalESSymbolConstructorType = getTypeOfSymbol (globalESSymbolConstructorSymbol);
1033810368 }
1033910369 else {
1034010370 globalTemplateStringsArrayType = unknownType;
0 commit comments