Skip to content

Commit

Permalink
Fix: no empty with braces with zero specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
The-x-Theorist authored and nicolo-ribaudo committed Feb 27, 2022
1 parent 7686fc0 commit adbc651
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/babel-generator/src/generators/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export function ImportDeclaration(this: Printer, node: t.ImportDeclaration) {
}

const specifiers = node.specifiers.slice(0);
const specifiersLength = specifiers.length;
if (specifiers?.length) {
// print "special" specifiers first
for (;;) {
Expand All @@ -209,6 +210,18 @@ export function ImportDeclaration(this: Printer, node: t.ImportDeclaration) {
this.token("}");
}

if (node.importKind !== "type" && node.importKind !== "typeof") {
this.space();
this.word("from");
this.space();
}
}

if (node.importKind === "type" || node.importKind === "typeof") {
if (!specifiersLength) {
this.token("{");
this.token("}");
}
this.space();
this.word("from");
this.space();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import typeof U from "x"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import typeof U from "x";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type {} from 'some-module';
export type {} from "some-module"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type {} from 'some-module';
export type {} from "some-module";

0 comments on commit adbc651

Please sign in to comment.