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(typescript): erase default export if exporting a TS type #10019

Merged
merged 1 commit into from May 23, 2019
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
10 changes: 10 additions & 0 deletions packages/babel-plugin-transform-typescript/src/index.js
Expand Up @@ -156,6 +156,16 @@ export default declare((api, { jsxPragma = "React" }) => {
}
},

ExportDefaultDeclaration(path, { exportableTSNames }) {
// remove whole declaration if it's exporting a TS type
if (
t.isIdentifier(path.node.declaration) &&
exportableTSNames.has(path.node.declaration.name)
) {
path.remove();
}
},

TSDeclareFunction(path) {
path.remove();
},
Expand Down
Expand Up @@ -42,6 +42,7 @@ function foo() {}
export { II3 as default, AA2 as A, BB2 as BB3, foo }; // only BB2 and foo

// export an interface before declaration
export default Bar;
export { Bar } // everything removed
export { Bar as Bar2, C2 as C4 } // only C4
interface Bar {}