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
Babel emits properties for type-only properties in typescript classes #7997
Comments
Hey @aaronjensen! 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 |
This is intentional, as we aren't trying to match typescript behavior/output, just allow you to use Babel with Typescript, so this is just spec behavior that is included in loose mode. Meaning the opposite thing was requested in #5056. So not a bug, just whether we would be ok with updating |
I see. Well, if it's to spec then I don't see any reason to make Anyway, I'll close this, thank you for responding! |
I think it's a valid request for loose mode though, can reopen as a separate request as well! Probably someone like @developit would appreciate. This goes into my desire to make more granular options + loose mode just turning on all the more granular ones. |
I think my concern would be that the behavior would change if one toggled from non-loose to loose. Perhaps it wouldn't change in a way that anyone would care about, but I cared about it 😄 |
Well that is expected, loose means you are opting into a less spec compliant output/semantics and you should know what you are getting into if you want less build size - a tradeoff. It's not a concern in the definition, just that most people don't understand what it means and we need better education/docs on all this (which I will try to do soon) |
Bug Report
Current Behavior
When a class is defined like:
And the typescript preset + class-properties is applied the generated code ends up including that property set to
void 0
which differs from TypeScript.Input Code
https://github.com/aaronjensen/typescript-babel-repro
Expected behavior/code
It should not emit the property unless it has an assignment.
Babel Configuration (.babelrc, package.json, cli command)
Note: loose is not important--the bug exists either way. It just simplifies the output.
Environment
The text was updated successfully, but these errors were encountered: