Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Consider export { type foo } as type-only usage #15494

Merged
merged 2 commits into from Mar 14, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/babel-plugin-transform-typescript/src/index.ts
Expand Up @@ -24,9 +24,12 @@ function isInType(path: NodePath) {
);
case "ExportSpecifier":
return (
// export { type foo };
path.parent.exportKind === "type" ||
// export type { foo };
// @ts-expect-error: DeclareExportDeclaration does not have `exportKind`
(path.parentPath as NodePath<t.ExportSpecifier>).parent.exportKind ===
"type"
"type"
);
default:
return false;
Expand Down
@@ -0,0 +1,4 @@
import { foo, bar, type baz } from "Foo";
export { type foo };
export type { bar };
export { baz };
@@ -0,0 +1 @@
export {};
@@ -0,0 +1,4 @@
import { foo, bar, type baz } from "Foo";
export { type foo };
export type { bar };
export { baz };
@@ -0,0 +1,8 @@
{
"plugins": [[
"transform-typescript",
{
"onlyRemoveTypeImports": true
}
]]
}
@@ -0,0 +1,2 @@
import { foo, bar } from "Foo";
export {};