Skip to content

Commit 5636655

Browse files
committed
report error if module name is empty
1 parent 90273f9 commit 5636655

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ namespace ts {
965965
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
966966
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
967967

968-
if (!moduleName) {
968+
if (moduleName === undefined) {
969969
return;
970970
}
971971
let isRelative = isExternalModuleNameRelative(moduleName);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/compiler/emptyModuleName.ts(1,20): error TS2307: Cannot find module ''.
2+
3+
4+
==== tests/cases/compiler/emptyModuleName.ts (1 errors) ====
5+
import * as A from "";
6+
~~
7+
!!! error TS2307: Cannot find module ''.
8+
class B extends A {
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [emptyModuleName.ts]
2+
import * as A from "";
3+
class B extends A {
4+
}
5+
6+
//// [emptyModuleName.js]
7+
var __extends = (this && this.__extends) || function (d, b) {
8+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9+
function __() { this.constructor = d; }
10+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11+
};
12+
var A = require("");
13+
var B = (function (_super) {
14+
__extends(B, _super);
15+
function B() {
16+
_super.apply(this, arguments);
17+
}
18+
return B;
19+
})(A);
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @module: commonjs
2+
import * as A from "";
3+
class B extends A {
4+
}

0 commit comments

Comments
 (0)