Skip to content

Commit

Permalink
Retain typescript export-from-source (#10167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolvereness authored and nicolo-ribaudo committed Jul 5, 2019
1 parent 106bb41 commit bff79e1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/babel-plugin-transform-typescript/src/index.js
Expand Up @@ -98,6 +98,7 @@ export default declare(
ExportNamedDeclaration(path) {
// remove export declaration if it's exporting only types
if (
!path.node.source &&
path.node.specifiers.length > 0 &&
!path.node.specifiers.find(exportSpecifier =>
path.scope.hasOwnBinding(exportSpecifier.local.name),
Expand All @@ -109,7 +110,10 @@ export default declare(

ExportSpecifier(path) {
// remove type exports
if (!path.scope.hasOwnBinding(path.node.local.name)) {
if (
!path.parent.source &&
!path.scope.hasOwnBinding(path.node.local.name)
) {
path.remove();
}
},
Expand Down
@@ -0,0 +1 @@
export default "foo";
@@ -0,0 +1 @@
export default "foo";
@@ -0,0 +1 @@
export { bar } from './bar';
@@ -0,0 +1 @@
export { bar } from './bar';

0 comments on commit bff79e1

Please sign in to comment.