@@ -5787,8 +5787,8 @@ module ts {
5787
5787
5788
5788
// See if we can index as a property.
5789
5789
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) {
5792
5792
var prop = getPropertyOfType(objectType, name);
5793
5793
if (prop) {
5794
5794
getNodeLinks(node).resolvedSymbol = prop;
@@ -5832,6 +5832,36 @@ module ts {
5832
5832
return unknownType;
5833
5833
}
5834
5834
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
+
5835
5865
function resolveUntypedCall(node: CallLikeExpression): Signature {
5836
5866
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
5837
5867
checkExpression((<TaggedTemplateExpression>node).template);
@@ -10334,7 +10364,7 @@ module ts {
10334
10364
globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
10335
10365
globalESSymbolType = getGlobalType("Symbol");
10336
10366
globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol");
10337
- globalESSymbolConstructorType = getTypeOfGlobalSymbol (globalESSymbolConstructorSymbol, /*arity*/ 0 );
10367
+ globalESSymbolConstructorType = getTypeOfSymbol (globalESSymbolConstructorSymbol);
10338
10368
}
10339
10369
else {
10340
10370
globalTemplateStringsArrayType = unknownType;
0 commit comments