Skip to content

Commit

Permalink
fix(typescript): erase default export if exporting a TS type (#10019)
Browse files Browse the repository at this point in the history
  • Loading branch information
airato authored and existentialism committed May 23, 2019
1 parent 9dd8825 commit a6392bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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 {}

0 comments on commit a6392bd

Please sign in to comment.