@@ -1826,8 +1826,8 @@ namespace ts {
1826
1826
nameArg: __String | Identifier | undefined,
1827
1827
isUse: boolean,
1828
1828
excludeGlobals = false,
1829
- getSpellingSuggstions = true): Symbol | undefined {
1830
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions , getSymbol);
1829
+ getSpellingSuggestions = true): Symbol | undefined {
1830
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions , getSymbol);
1831
1831
}
1832
1832
1833
1833
function resolveNameHelper(
@@ -2683,7 +2683,7 @@ namespace ts {
2683
2683
? Diagnostics._0_was_exported_here
2684
2684
: Diagnostics._0_was_imported_here;
2685
2685
2686
- const name = unescapeLeadingUnderscores (typeOnlyDeclaration.name.escapedText );
2686
+ const name = moduleExportNameText (typeOnlyDeclaration.name);
2687
2687
addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
2688
2688
}
2689
2689
}
@@ -3305,7 +3305,7 @@ namespace ts {
3305
3305
/**
3306
3306
* Resolves a qualified name and any involved aliases.
3307
3307
*/
3308
- function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol | undefined {
3308
+ function resolveEntityName(name: EntityNameOrEntityNameExpression | ModuleExportName , meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol | undefined {
3309
3309
if (nodeIsMissing(name)) {
3310
3310
return undefined;
3311
3311
}
@@ -3390,6 +3390,11 @@ namespace ts {
3390
3390
return undefined;
3391
3391
}
3392
3392
}
3393
+ else if (name.kind === SyntaxKind.StringLiteral) {
3394
+ const message = Diagnostics.Cannot_find_name_0;
3395
+ symbol = getMergedSymbol(resolveName(location || name, moduleExportNameTextEscaped(name), meaning, ignoreErrors ? undefined : message, moduleExportNameTextEscaped(name), /*isUse*/ true, /** excludeGlobals */true));
3396
+ if (!symbol) return undefined;
3397
+ }
3393
3398
else {
3394
3399
throw Debug.assertNever(name, "Unknown entity name kind.");
3395
3400
}
@@ -6952,7 +6957,7 @@ namespace ts {
6952
6957
if (!e.propertyName) {
6953
6958
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
6954
6959
const indices = indicesOf(statements);
6955
- const associatedIndices = filter(indices, i => nodeHasName(statements[i], e.name));
6960
+ const associatedIndices = filter(indices, i => nodeHasName(statements[i], moduleExportNameText( e.name) ));
6956
6961
if (length(associatedIndices) && every(associatedIndices, i => canHaveExportModifier(statements[i]))) {
6957
6962
for (const index of associatedIndices) {
6958
6963
statements[index] = addExportModifier(statements[index] as Extract<HasModifiers, Statement>);
@@ -7615,7 +7620,7 @@ namespace ts {
7615
7620
function getSomeTargetNameFromDeclarations(declarations: Declaration[] | undefined) {
7616
7621
return firstDefined(declarations, d => {
7617
7622
if (isImportSpecifier(d) || isExportSpecifier(d)) {
7618
- return idText (d.propertyName || d.name);
7623
+ return moduleExportNameText (d.propertyName || d.name);
7619
7624
}
7620
7625
if (isBinaryExpression(d) || isExportAssignment(d)) {
7621
7626
const expression = isExportAssignment(d) ? d.expression : d.right;
@@ -8513,10 +8518,10 @@ namespace ts {
8513
8518
}
8514
8519
}
8515
8520
8516
- function collectLinkedAliases(node: Identifier , setVisibility?: boolean): Node[] | undefined {
8521
+ function collectLinkedAliases(node: ModuleExportName , setVisibility?: boolean): Node[] | undefined {
8517
8522
let exportSymbol: Symbol | undefined;
8518
8523
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
8519
- exportSymbol = resolveName(node, node.escapedText , SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false);
8524
+ exportSymbol = resolveName(node, moduleExportNameTextEscaped( node) , SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, moduleExportNameTextEscaped( node) , /*isUse*/ false);
8520
8525
}
8521
8526
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
8522
8527
exportSymbol = getTargetOfExportSpecifier(node.parent as ExportSpecifier, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
@@ -40863,7 +40868,7 @@ namespace ts {
40863
40868
const message = isType
40864
40869
? Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled
40865
40870
: Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled;
40866
- const name = idText (node.kind === SyntaxKind.ImportSpecifier ? node.propertyName || node.name : node.name);
40871
+ const name = moduleExportNameText (node.kind === SyntaxKind.ImportSpecifier ? node.propertyName || node.name : node.name);
40867
40872
addTypeOnlyDeclarationRelatedInfo(
40868
40873
error(node, message, name),
40869
40874
isType ? undefined : typeOnlyAlias,
@@ -40883,7 +40888,7 @@ namespace ts {
40883
40888
const message = isType
40884
40889
? Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type
40885
40890
: Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isolatedModules_is_enabled;
40886
- const name = idText (node.propertyName || node.name);
40891
+ const name = moduleExportNameText (node.propertyName || node.name);
40887
40892
addTypeOnlyDeclarationRelatedInfo(
40888
40893
error(node, message, name),
40889
40894
isType ? undefined : typeOnlyAlias,
@@ -40941,7 +40946,7 @@ namespace ts {
40941
40946
checkCollisionsForDeclarationName(node, node.name);
40942
40947
checkAliasSymbol(node);
40943
40948
if (node.kind === SyntaxKind.ImportSpecifier &&
40944
- idText (node.propertyName || node.name) === "default" &&
40949
+ moduleExportNameTextEscaped (node.propertyName || node.name) === "default" &&
40945
40950
getESModuleInterop(compilerOptions) &&
40946
40951
moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
40947
40952
checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
@@ -41178,10 +41183,10 @@ namespace ts {
41178
41183
if (!node.parent.parent.moduleSpecifier) {
41179
41184
const exportedName = node.propertyName || node.name;
41180
41185
// find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases)
41181
- const symbol = resolveName(exportedName, exportedName.escapedText , SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias,
41186
+ const symbol = resolveName(exportedName, moduleExportNameTextEscaped( exportedName) , SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias,
41182
41187
/*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
41183
41188
if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
41184
- error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, idText (exportedName));
41189
+ error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, moduleExportNameText (exportedName));
41185
41190
}
41186
41191
else {
41187
41192
markExportAsReferenced(node);
@@ -41195,7 +41200,7 @@ namespace ts {
41195
41200
if (getESModuleInterop(compilerOptions) &&
41196
41201
moduleKind !== ModuleKind.System &&
41197
41202
(moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) &&
41198
- idText (node.propertyName || node.name) === "default") {
41203
+ moduleExportNameTextEscaped (node.propertyName || node.name) === "default") {
41199
41204
checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
41200
41205
}
41201
41206
}
0 commit comments