Skip to content

Commit 5219200

Browse files
authored
Merge pull request microsoft#20671 from Kingwl/fix-import-not-existed-module
error if import empty object form module not existed
2 parents e26745f + eba4d36 commit 5219200

6 files changed

+28
-1
lines changed

src/compiler/checker.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -24465,7 +24465,10 @@ namespace ts {
2446524465
checkImportBinding(importClause.namedBindings);
2446624466
}
2446724467
else {
24468-
forEach(importClause.namedBindings.elements, checkImportBinding);
24468+
const moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
24469+
if (moduleExisted) {
24470+
forEach(importClause.namedBindings.elements, checkImportBinding);
24471+
}
2446924472
}
2447024473
}
2447124474
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests/cases/conformance/es6/modules/importEmptyFromModuleNotExisted.ts(1,16): error TS2307: Cannot find module 'module-not-existed'.
2+
3+
4+
==== tests/cases/conformance/es6/modules/importEmptyFromModuleNotExisted.ts (1 errors) ====
5+
import {} from 'module-not-existed'
6+
~~~~~~~~~~~~~~~~~~~~
7+
!!! error TS2307: Cannot find module 'module-not-existed'.
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [importEmptyFromModuleNotExisted.ts]
2+
import {} from 'module-not-existed'
3+
4+
5+
//// [importEmptyFromModuleNotExisted.js]
6+
"use strict";
7+
exports.__esModule = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/conformance/es6/modules/importEmptyFromModuleNotExisted.ts ===
2+
import {} from 'module-not-existed'
3+
No type information for this code.
4+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/conformance/es6/modules/importEmptyFromModuleNotExisted.ts ===
2+
import {} from 'module-not-existed'
3+
No type information for this code.
4+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import {} from 'module-not-existed'

0 commit comments

Comments
 (0)