Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Fix detection of export syntax in declaration file #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,7 @@ function getDtsExportKind(sourceFile: ts.SourceFile): InferenceResult<DtsExportK
if (matches(sourceFile, isExportEquals)) {
return inferenceSuccess(DtsExportKind.ExportEquals);
}
if (matches(sourceFile, isExportConstruct)) {
return inferenceSuccess(DtsExportKind.ES6Like);
}
return inferenceError("Could not infer export kind of declaration file.");
return inferenceSuccess(DtsExportKind.ES6Like);
}

const exportEqualsSymbolName = "export=";
Expand Down Expand Up @@ -814,19 +811,6 @@ function isExportEquals(node: ts.Node): boolean {
return ts.isExportAssignment(node) && !!node.isExportEquals;
}

function isExportConstruct(node: ts.Node): boolean {
return ts.isExportAssignment(node)
|| ts.isExportDeclaration(node)
|| hasExportModifier(node);
}

function hasExportModifier(node: ts.Node): boolean {
if (node.modifiers) {
return node.modifiers.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword);
}
return false;
}

function matches(srcFile: ts.SourceFile, predicate: (n: ts.Node) => boolean): boolean {
function matchesNode(node: ts.Node): boolean {
if (predicate(node)) return true;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.