diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa2207d5431..a6d95fd3d42 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11833,7 +11833,8 @@ module ts { if (languageVersion === ScriptTarget.ES3) { defaultKeyword = "[\"default\"]"; - } else { + } + else { defaultKeyword = ".default"; } return getGeneratedNameForNode(node.parent) + defaultKeyword; diff --git a/src/services/services.ts b/src/services/services.ts index 52ffc75efe4..1b5ba6752de 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4988,19 +4988,6 @@ module ts { } function getDeclaredName(symbol: Symbol, location: Node) { - // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(symbol.declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); - - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - let name: string; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - // If this is an export or import specifier it could have been renamed using the as syntax. // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) // so check for the propertyName. @@ -5008,7 +4995,7 @@ module ts { return location.getText(); } - name = typeChecker.symbolToString(symbol); + let name = typeChecker.symbolToString(symbol); return stripQuotes(name); } @@ -5022,7 +5009,12 @@ module ts { } // Special case for function expressions, whose names are solely local to their bodies. - let functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined); + // TODO (drosen): Why would we have to lookup the interned name for a function expression? + // Shouldn't we have found a scope? Consider a 'Debug.fail()'. + let functionExpression: FunctionExpression; + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === SyntaxKind.FunctionExpression) { + functionExpression = symbol.valueDeclaration; + } // When a name gets interned into a SourceFile's 'identifiers' Map, // its name is escaped and stored in the same way its symbol name/identifier