mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Merge pull request #25445 from a-tarasyuk/bug/24542-bad-error-message-for-import-ing-an-export
24542 - bad error message for `import *`-ing an `export=`
This commit is contained in:
@@ -2408,11 +2408,18 @@ namespace ts {
|
||||
// combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable).
|
||||
function resolveESModuleSymbol(moduleSymbol: Symbol | undefined, referencingLocation: Node, dontResolveAlias: boolean): Symbol | undefined {
|
||||
const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
|
||||
|
||||
if (!dontResolveAlias && symbol) {
|
||||
if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable)) && !getDeclarationOfKind(symbol, SyntaxKind.SourceFile)) {
|
||||
error(referencingLocation, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol!));
|
||||
const compilerOptionName = moduleKind >= ModuleKind.ES2015
|
||||
? "allowSyntheticDefaultImports"
|
||||
: "esModuleInterop";
|
||||
|
||||
error(referencingLocation, Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
if (compilerOptions.esModuleInterop) {
|
||||
const referenceParent = referencingLocation.parent;
|
||||
if (
|
||||
|
||||
@@ -1776,7 +1776,7 @@
|
||||
"category": "Error",
|
||||
"code": 2496
|
||||
},
|
||||
"Module '{0}' resolves to a non-module entity and cannot be imported using this construct.": {
|
||||
"This module can only be referenced with ECMAScript imports/exports by turning on the '{0}' flag and referencing its default export.": {
|
||||
"category": "Error",
|
||||
"code": 2497
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user