-
-
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
Add 2022-03 decorators version (stage 3) #14836
Add 2022-03 decorators version (stage 3) #14836
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52770/ |
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.
Only skimmed and left a quick question - thanks for working on this!
expect(bContext.static).toBe(false); | ||
expect(bContext.private).toBe(true); | ||
expect(typeof bContext.addInitializer).toBe('function'); | ||
expect(typeof bContext.setMetadata).toBe('function'); |
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.
I'm not sure what the expected scope for the babel implementation are but setMetadata
/getMetadata
have been removed in the March update: tc39/proposal-decorators@5c1cc15
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.
Oh yes thanks I should remove them! Are there any other runtime changes?
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.
I'll let @pzuraq take that. I've been only following the proposal progress on the sidelines. AFAIK the is*
renaming and metadata split were the two notable changes. But it looks like there also might have been a unification of access
..? tc39/proposal-decorators@13e07b3
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.
Yes, unification of access
was one other change we made. I'll comment with a list of all changes
Thanks for pushing this forward @nicolo-ribaudo! I've been meaning to and just haven't had time. Here are all the major changes we should make sure to get in this round:
I believe that's everything, reviewing the repo issues and PRs. I haven't had a chance to dig back into the actual spec changes, I'll try to find some time this week to review those and make sure nothing slipped between the cracks. |
d7c3717
to
cda1cec
Compare
cda1cec
to
f0a850b
Compare
Thanks @pzuraq! I updated the PR. |
It seems to me #14666 should be part of this PR, but that one is pending tc39/ecma262#2417 (comment). I think we intend to allow |
@@ -0,0 +1,619 @@ | |||
/* @minVersion 7.17.8 */ |
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.
Should it be 7.19.xx
?
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.
It needs to be updated when publishing, some tests fail when helpers specify a future version.
ca5415c
to
65de4e7
Compare
492d15b
to
56100c4
Compare
I don't know why the e2e test is failing 😕 |
I can reproduce the failure locally downloading the CI artifact |
fa9b7e6
to
6032754
Compare
6032754
to
8dd4406
Compare
CI is green; please review again! (https://github.com/babel/babel/pull/14836/files/915df0ba082dd55dfe5ddc0abf0967ac2ecb571c..8dd440618dbd1fd75fe467b272ccb1859f8c7865) |
Since #14353 is merged and shipped in decorator version
|
I would word it as:
because the spec updates we merged to 2021-12 are all backward compatible anyway. |
I prefer to always avoid it, it's simpler and generates future-proof code! EDIT: It already works like that: babel/packages/babel-generator/test/fixtures/decorators/decorator-parenthesized-expression/input.js Lines 22 to 25 in 14c3f12
babel/packages/babel-generator/test/fixtures/decorators/decorator-parenthesized-expression/output.js Lines 23 to 26 in 14c3f12
|
Not if one enabled |
7006391
to
4d69407
Compare
2767995
to
03f49bb
Compare
4d69407
to
08bd28c
Compare
This commits add a new `allowCallParenthesized` option to the decorators parser plugin: when set to `false`, `@(...)()`-style decorators are allowed to match the stage 3 proposal presented in March 2022. It will default to `false` in Babel 8 (we might just remove the option)
This aligns with the Babel 8 behavior
03f49bb
to
d0ded5b
Compare
* Copy `applyDecs`->`applyDecs2203` helper, and `2021-12`->`2022-03` tests * Avoid conflicting fn names in helpers * Add `2022-03` decorators version * Rename `isPrivate`/`isStatic`->`private`/`static` * Disallow `@(...)()` in 2022-03 decorators This commits add a new `allowCallParenthesized` option to the decorators parser plugin: when set to `false`, `@(...)()`-style decorators are allowed to match the stage 3 proposal presented in March 2022. It will default to `false` in Babel 8 (we might just remove the option) * Disallow `decoratorsBeforeExport` option with 2022-03 decorators This aligns with the Babel 8 behavior * Remove `.initializer` fallback for accessor properties * Remove `.initializer` fallback for accessor properties * Expose `.access` for public class elements * Remove `getMetadata`/`setMetadata` * Make the parser error recoverable * Print necessary parentheses in generator
* Copy `applyDecs`->`applyDecs2203` helper, and `2021-12`->`2022-03` tests * Avoid conflicting fn names in helpers * Add `2022-03` decorators version * Rename `isPrivate`/`isStatic`->`private`/`static` * Disallow `@(...)()` in 2022-03 decorators This commits add a new `allowCallParenthesized` option to the decorators parser plugin: when set to `false`, `@(...)()`-style decorators are allowed to match the stage 3 proposal presented in March 2022. It will default to `false` in Babel 8 (we might just remove the option) * Disallow `decoratorsBeforeExport` option with 2022-03 decorators This aligns with the Babel 8 behavior * Remove `.initializer` fallback for accessor properties * Remove `.initializer` fallback for accessor properties * Expose `.access` for public class elements * Remove `getMetadata`/`setMetadata` * Make the parser error recoverable * Print necessary parentheses in generator
* Copy `applyDecs`->`applyDecs2203` helper, and `2021-12`->`2022-03` tests * Avoid conflicting fn names in helpers * Add `2022-03` decorators version * Rename `isPrivate`/`isStatic`->`private`/`static` * Disallow `@(...)()` in 2022-03 decorators This commits add a new `allowCallParenthesized` option to the decorators parser plugin: when set to `false`, `@(...)()`-style decorators are allowed to match the stage 3 proposal presented in March 2022. It will default to `false` in Babel 8 (we might just remove the option) * Disallow `decoratorsBeforeExport` option with 2022-03 decorators This aligns with the Babel 8 behavior * Remove `.initializer` fallback for accessor properties * Remove `.initializer` fallback for accessor properties * Expose `.access` for public class elements * Remove `getMetadata`/`setMetadata` * Make the parser error recoverable * Print necessary parentheses in generator
Fixes #1, Fixes #2
This PR adds a new version of the decorators plugin, representing the stage 3 proposal that reached consensus in the March 2022 TC39 meeting: #14836 (comment)
Also, the
decoratorsBeforeExport
option is disallowed with the new version and decorators are always afterexport
(this aligns with the Babel 8 behavior).ℹ️ The first two commits only copy the 2021-12 files to 2022-03. I suggest hiding it when reviewing (https://github.com/babel/babel/pull/14836/files/915df0ba082dd55dfe5ddc0abf0967ac2ecb571c..8dd440618dbd1fd75fe467b272ccb1859f8c7865), to see the diff between the 2022-03 code/tests and the 2021-12 code/tests.
cc @pzuraq @jkrems