Skip to content

Commit eba4d36

Browse files
committed
error if import empty object form module not existed
1 parent b31aa4e commit eba4d36

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23852,7 +23852,10 @@ namespace ts {
2385223852
checkImportBinding(importClause.namedBindings);
2385323853
}
2385423854
else {
23855-
forEach(importClause.namedBindings.elements, checkImportBinding);
23855+
const moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
23856+
if (moduleExisted) {
23857+
forEach(importClause.namedBindings.elements, checkImportBinding);
23858+
}
2385623859
}
2385723860
}
2385823861
}
Lines changed: 8 additions & 0 deletions
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+
Lines changed: 7 additions & 0 deletions
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;
Lines changed: 4 additions & 0 deletions
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.
Lines changed: 4 additions & 0 deletions
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import {} from 'module-not-existed'

0 commit comments

Comments
 (0)