fix(typescript): erase default export if exporting a TS type (#10019)

This commit is contained in:
Airat Aminev 2019-05-23 14:58:24 -07:00 committed by Brian Ng
parent 9dd8825eff
commit a6392bd636
2 changed files with 11 additions and 0 deletions

View File

@ -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();
},

View File

@ -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 {}