-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Typescript: Avoid stripping class properties when a decorator is set #8238
Conversation
@@ -157,10 +157,6 @@ export default declare((api, { jsxPragma = "React" }) => { | |||
|
|||
ClassProperty(path) { | |||
const { node } = path; | |||
if (!node.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is a duplicate of the one in the Class
visitor.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8469/ |
I don't have enough context here, sorry. Why do we want to emit decorators syntax? Shoudln't we strip out unsupported syntax? |
The typescript plugin should leave decorators there: they will be handled by the decorators plugin. |
@nicolo-ribaudo @xtuc are you good with this changes? If so, shall bribe @hzoo or @loganfsmyth to merge this? :) |
I'm 👍 only if we can make sure the user is aware of this behavior:
|
I don't think that we should, the same way we don't warn if class properties or other proposals supported by typescript are not transpiled. |
That's right @nicolo-ribaudo, I was wondering if the "why it didn't transform it" would be confusing for users or not. |
If the user just adds the typescript plugin, Babylon throws and suggests the user to add the |
This is fine, it's expected behavior 👍. |
Ah yes Nicolo, perfect! |
Current behavior:
The
babel-plugin-transform-typescript
removes class properties without value regardless if decorators are assigned to it or not.Expected behavior:
The
babel-plugin-transform-typescript
should only remove a class property if it has no value and no decorators.REPL example