Ensure class decorators can access decorated non-static members#15332
Ensure class decorators can access decorated non-static members#15332JLHwung merged 7 commits intobabel:mainfrom
Conversation
| get c() { | ||
| return applyClassDecs(targetClass, classDecs); | ||
| }, |
There was a problem hiding this comment.
The class decorators are applied after member decorators are applied and bound to the initializer locals, such as initA, initProto, etc.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53767/ |
|
The CI failure looks related. |
|
Yes. CI is failing for the same reason of #14836 (comment). I will investigate how I can resolve it without renaming functions. |
|
Helper diff: https://www.diffchecker.com/wMz5rhsx/ |
|
The e2e build was failing because we simply concat all helper codes in babel/packages/babel-core/src/tools/build-external-helpers.ts Lines 172 to 181 in 6e03af1 which forms the content of the virtual A proper fix would be to handle function name collisions in |
There was a problem hiding this comment.
@JLHwung The Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: error has been removed from the new helper: is it now supported, or was that error just unreachable?
This PR slightly increases the output size:
It's fine, decorators are already considered heavy and this is just a few more bytes.
That part is not changed: 5dbfd3d#diff-1055897236adecf62778dc76b5b6168bc5c14344106b32a8a14c78479f601cb2R397 The only revisions are that |
…-03.ts Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
applyDecs2203Rbased onapplyDecs2203, which lazily apply class decorations so that the class decorate will have access to the decorated non-static class elements. Because the return type is changed, we have to create a new runtime. In Babel 8 we can remove deprecated helpersapplyDecs2203andapplyDecsThis PR slightly increases the output size:
We could preserve the output size if
applyDecs2203Rcan return a customized iterator, i.e.but then our runtime helper will not be ES5-compliant. We can revisit this approach if we bump helper targets in the future.