Skip to content

Commit fb99a66

Browse files
committed
do not error if typings for external library is empty .d.ts file
1 parent 0855933 commit fb99a66

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

src/compiler/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ namespace ts {
14901490
if (importedFile && resolution.isExternalLibraryImport) {
14911491
// Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files,
14921492
// this check is ok. Otherwise this would be never true for javascript file
1493-
if (!isExternalModule(importedFile)) {
1493+
if (!isExternalModule(importedFile) && importedFile.statements.length) {
14941494
const start = getTokenPosOfNode(file.imports[i], file);
14951495
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
14961496
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/compiler/noErrorOnEmptyDts.ts] ////
2+
3+
//// [test.d.ts]
4+
5+
6+
// comment
7+
8+
//// [main.ts]
9+
import "test"
10+
11+
//// [main.js]
12+
"use strict";
13+
require("test");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== c:/node_modules/test.d.ts ===
2+
3+
No type information for this code.
4+
No type information for this code.// comment
5+
No type information for this code.
6+
No type information for this code.=== c:/app/main.ts ===
7+
import "test"
8+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== c:/node_modules/test.d.ts ===
2+
3+
No type information for this code.
4+
No type information for this code.// comment
5+
No type information for this code.
6+
No type information for this code.=== c:/app/main.ts ===
7+
import "test"
8+
No type information for this code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @module: commonjs
2+
3+
// @filename: c:/node_modules/test.d.ts
4+
5+
// comment
6+
7+
// @filename: c:/app/main.ts
8+
import "test"

0 commit comments

Comments
 (0)