@@ -1826,8 +1826,8 @@ namespace ts {
18261826 nameArg: __String | Identifier | undefined,
18271827 isUse: boolean,
18281828 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);
18311831 }
18321832
18331833 function resolveNameHelper(
@@ -2683,7 +2683,7 @@ namespace ts {
26832683 ? Diagnostics._0_was_exported_here
26842684 : Diagnostics._0_was_imported_here;
26852685
2686- const name = unescapeLeadingUnderscores (typeOnlyDeclaration.name.escapedText );
2686+ const name = moduleExportNameText (typeOnlyDeclaration.name);
26872687 addRelatedInfo(error(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
26882688 }
26892689 }
@@ -3305,7 +3305,7 @@ namespace ts {
33053305 /**
33063306 * Resolves a qualified name and any involved aliases.
33073307 */
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 {
33093309 if (nodeIsMissing(name)) {
33103310 return undefined;
33113311 }
@@ -3390,6 +3390,11 @@ namespace ts {
33903390 return undefined;
33913391 }
33923392 }
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+ }
33933398 else {
33943399 throw Debug.assertNever(name, "Unknown entity name kind.");
33953400 }
@@ -6952,7 +6957,7 @@ namespace ts {
69526957 if (!e.propertyName) {
69536958 // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
69546959 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) ));
69566961 if (length(associatedIndices) && every(associatedIndices, i => canHaveExportModifier(statements[i]))) {
69576962 for (const index of associatedIndices) {
69586963 statements[index] = addExportModifier(statements[index] as Extract<HasModifiers, Statement>);
@@ -7615,7 +7620,7 @@ namespace ts {
76157620 function getSomeTargetNameFromDeclarations(declarations: Declaration[] | undefined) {
76167621 return firstDefined(declarations, d => {
76177622 if (isImportSpecifier(d) || isExportSpecifier(d)) {
7618- return idText (d.propertyName || d.name);
7623+ return moduleExportNameText (d.propertyName || d.name);
76197624 }
76207625 if (isBinaryExpression(d) || isExportAssignment(d)) {
76217626 const expression = isExportAssignment(d) ? d.expression : d.right;
@@ -8513,10 +8518,10 @@ namespace ts {
85138518 }
85148519 }
85158520
8516- function collectLinkedAliases(node: Identifier , setVisibility?: boolean): Node[] | undefined {
8521+ function collectLinkedAliases(node: ModuleExportName , setVisibility?: boolean): Node[] | undefined {
85178522 let exportSymbol: Symbol | undefined;
85188523 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);
85208525 }
85218526 else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
85228527 exportSymbol = getTargetOfExportSpecifier(node.parent as ExportSpecifier, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
@@ -40863,7 +40868,7 @@ namespace ts {
4086340868 const message = isType
4086440869 ? Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled
4086540870 : 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);
4086740872 addTypeOnlyDeclarationRelatedInfo(
4086840873 error(node, message, name),
4086940874 isType ? undefined : typeOnlyAlias,
@@ -40883,7 +40888,7 @@ namespace ts {
4088340888 const message = isType
4088440889 ? Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type
4088540890 : 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);
4088740892 addTypeOnlyDeclarationRelatedInfo(
4088840893 error(node, message, name),
4088940894 isType ? undefined : typeOnlyAlias,
@@ -40941,7 +40946,7 @@ namespace ts {
4094140946 checkCollisionsForDeclarationName(node, node.name);
4094240947 checkAliasSymbol(node);
4094340948 if (node.kind === SyntaxKind.ImportSpecifier &&
40944- idText (node.propertyName || node.name) === "default" &&
40949+ moduleExportNameTextEscaped (node.propertyName || node.name) === "default" &&
4094540950 getESModuleInterop(compilerOptions) &&
4094640951 moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) {
4094740952 checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
@@ -41178,10 +41183,10 @@ namespace ts {
4117841183 if (!node.parent.parent.moduleSpecifier) {
4117941184 const exportedName = node.propertyName || node.name;
4118041185 // 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,
4118241187 /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
4118341188 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));
4118541190 }
4118641191 else {
4118741192 markExportAsReferenced(node);
@@ -41195,7 +41200,7 @@ namespace ts {
4119541200 if (getESModuleInterop(compilerOptions) &&
4119641201 moduleKind !== ModuleKind.System &&
4119741202 (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) &&
41198- idText (node.propertyName || node.name) === "default") {
41203+ moduleExportNameTextEscaped (node.propertyName || node.name) === "default") {
4119941204 checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
4120041205 }
4120141206 }
0 commit comments