Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit 36b412c

Browse files
committed
fix: proper module resolution for .d.ts files
1 parent acd13c2 commit 36b412c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/deps.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export function isTypeDeclaration(fileName: string): boolean {
2020
}
2121

2222
function isImportOrExportDeclaration(node: ts.Node) {
23-
return (!!(<any>node).exportClause || !!(<any>node).importClause)
24-
&& (<any>node).moduleSpecifier;
23+
return !!(<any>node).moduleSpecifier;
2524
}
2625

2726
function isImportEqualsDeclaration(node: ts.Node) {
@@ -75,21 +74,21 @@ export class FileAnalyzer {
7574

7675
findImportDeclarations(fileName: string): ts.ResolvedModule[] {
7776
let sourceFile = this.state.getSourceFile(fileName);
78-
let isDeclaration = isTypeDeclaration(fileName);
7977

8078
let imports = [];
8179
let visit = (node: ts.Node) => {
82-
if (!isDeclaration && isImportEqualsDeclaration(node)) {
80+
if (isImportEqualsDeclaration(node)) {
8381
// we need this check to ensure that we have an external import
8482
let importPath = (<any>node).moduleReference.expression.text;
8583
imports.push(importPath);
86-
} else if (!isDeclaration && isImportOrExportDeclaration(node)) {
84+
} else if (isImportOrExportDeclaration(node)) {
8785
let importPath = (<any>node).moduleSpecifier.text;
8886
imports.push(importPath);
8987
}
9088
};
9189

9290
imports.push.apply(imports, sourceFile.referencedFiles.map(file => file.fileName));
91+
9392
this.state.ts.forEachChild(sourceFile, visit);
9493

9594
let resolvedImports = imports.map((importPath) => {

0 commit comments

Comments
 (0)