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
Exporting of TypeScript types separate from their declarations doesn't get erased #6065
Comments
Hey @pelotom! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
Hi @pelotom, we haven't written the guide for this yet, but this plugin needs to be used with the import { T } from "./other-module";
export { T }; // Is this a type export? In babel we transpile files independently, so we can't access the information we would need there. |
@andy-ms is something like |
Yes, that should work since we can use local information to determine that it's a type-only import. |
Experiencing the same error:
Valid typescript that does not work with current babel-preset-typescript |
Hi @rodrigopivi, see #6667. In the meanwhile you could replace the binding pattern |
@andy-ms it seems like the original code should be reasonable to handle even in type Foo = number
export { Foo } I realize that Just like how Babel (and TS) will remove imported identifiers that are only used as types in the file, couldn't it also remove exported identifiers that are only declared as types in the file? It looks to me like the TypeScript compiler already does this with |
Hi, I just tried out the new
babel-preset-typescript
in version 7.0.0-alpha.19 with much anticipation. Unfortunately I discovered that it doesn't erase types that are exported separate from their declaration:gets transformed to
which of course generates an error if you try to run it:
ReferenceError: Foo is not defined
. It correctly deletes the export if you writeThe text was updated successfully, but these errors were encountered: