Skip to content

Commit b58f16b

Browse files
Don't intern all strings and numbers. Just the ones used as declaration names.
1 parent 419d379 commit b58f16b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/services/services.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -4044,14 +4044,30 @@ module ts {
40444044
break;
40454045
case SyntaxKind.StringLiteral:
40464046
case SyntaxKind.NumericLiteral:
4047-
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
4047+
// We want to store any numbers/strings if they were a name that could be
4048+
// related to a declaration. So, if we have 'import x = require("something")'
4049+
// then we want 'something' to be in the name table. Similarly, if we have
4050+
// "a['propname']" then we want to store "propname" in the name table.
4051+
if (isDeclarationName(node) ||
4052+
node.parent.kind === SyntaxKind.ExternalModuleReference ||
4053+
isArgumentOfElementAccessExpression(node)) {
4054+
4055+
nameTable[(<LiteralExpression>node).text] = (<LiteralExpression>node).text;
4056+
}
40484057
break;
40494058
default:
40504059
forEachChild(node, walk);
40514060
}
40524061
}
40534062
}
40544063

4064+
function isArgumentOfElementAccessExpression(node: Node) {
4065+
return node &&
4066+
node.parent &&
4067+
node.parent.kind === SyntaxKind.ElementAccessExpression &&
4068+
(<ElementAccessExpression>node.parent).argumentExpression === node;
4069+
}
4070+
40554071
function getReferencesForNode(node: Node, sourceFiles: SourceFile[], searchOnlyInCurrentFile: boolean, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
40564072
// Labels
40574073
if (isLabelName(node)) {

0 commit comments

Comments
 (0)