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

Support type-only imports and exports #224

Merged
merged 1 commit into from
Mar 1, 2021
Merged
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
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";