Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Support type-only imports and exports (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbarabash authored Mar 1, 2021
1 parent 656463d commit e4fdd54
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,24 +692,20 @@ const transform = {
},
ExportDeclaration: {
exit(path) {
if (path.node.exportKind == "type") {
path.node.exportKind = "value";
}

if (path.node.source) {
stripSuffixFromImportSource(path);
}
}
},
ImportDeclaration: {
exit(path) {
path.node.importKind = "value";
// TODO(#223): Handle "typeof" imports
stripSuffixFromImportSource(path);
}
},
ImportSpecifier: {
exit(path) {
path.node.importKind = "value";
// TODO(#223): Handle "typeof" imports
}
},
DeclareVariable: {
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/convert/imports/default_import/ts.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import A from "./depsA";
import B from "../depsB";
import type A from "./depsA";
import type B from "../depsB";
4 changes: 2 additions & 2 deletions test/fixtures/convert/imports/export_type_from/ts.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { A, B } from "./depA";
export { C, D } from "../depB";
export type { A, B } from "./depA";
export type { C, D } from "../depB";
2 changes: 1 addition & 1 deletion test/fixtures/convert/imports/import_node_module/ts.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import A from "dep";
import type A from "dep";
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { A, B } from "./depA";
import { C, D } from "../depB";
import type { A, B } from "./depA";
import type { C, D } from "../depB";
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { A, B, C } from "./depA";
import { D, E, F } from "../depB";
import { type A, type B, C } from "./depA";
import { type D, type E, F } from "../depB";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { A } from "./depA.js";
import type { B } from "./depA.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { A } from "./depA";
import type { B } from "./depA";

0 comments on commit e4fdd54

Please sign in to comment.