Skip to content

Commit 4248762

Browse files
committed
Bugfix: more cases in types publishing infra
- Remove a needless runtime type check in one of the visitors. - Remove `declare` from interface declarations.
1 parent bd784a7 commit 4248762

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

types/publish.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,19 @@ export function rewriteModule(code, moduleName) {
542542

543543
// Remove `declare` from `declare function` in the top-level module.
544544
visitTSDeclareFunction(path) {
545-
if (isTSDeclareFunction(path.node) && !hasParentModuleDeclarationBlock(path)) {
545+
if (!hasParentModuleDeclarationBlock(path)) {
546546
path.node.declare = false;
547547
}
548548
this.traverse(path);
549549
},
550550

551+
visitTSInterfaceDeclaration(path) {
552+
if (!hasParentModuleDeclarationBlock(path)) {
553+
path.node.declare = false;
554+
}
555+
this.traverse(false);
556+
},
557+
551558
// Remove `declare` from `declare enum` in the top-level module.
552559
visitTSEnumDeclaration(path) {
553560
if (isTSEnumDeclaration(path.node) && !hasParentModuleDeclarationBlock(path)) {
@@ -584,6 +591,14 @@ export function rewriteModule(code, moduleName) {
584591
this.traverse(path);
585592
},
586593

594+
visitExportAllDeclaration(path) {
595+
let specifier = path.node.source;
596+
if (isStringLiteral(specifier)) {
597+
specifier.value = normalizeSpecifier(moduleName, specifier.value);
598+
}
599+
this.traverse(path);
600+
},
601+
587602
// We need to rewrite annotations like `export const: import('./foo').foo`
588603
// to use relative paths, as well.
589604
visitTSImportType(path) {

0 commit comments

Comments
 (0)