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
Improve decorated private method check #16226
Merged
JLHwung
merged 5 commits into
babel:main
from
JLHwung:improve-decorated-private-method-check
Jan 19, 2024
Merged
Improve decorated private method check #16226
JLHwung
merged 5 commits into
babel:main
from
JLHwung:improve-decorated-private-method-check
Jan 19, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JLHwung
added
PR: Bug Fix 🐛
A type of pull request used for our changelog categories
Spec: Decorators
labels
Jan 18, 2024
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56170/ |
liuxingbaoyu
approved these changes
Jan 19, 2024
nicolo-ribaudo
approved these changes
Jan 19, 2024
parentParentPath.node.left === parentPath.node) | ||
) { | ||
throw path.buildCodeFrameError( | ||
`Decorated private methods are not updatable, but "#${path.node.id.name}" is updated via this expression.`, |
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.
Suggested change
`Decorated private methods are not updatable, but "#${path.node.id.name}" is updated via this expression.`, | |
`Decorated private methods are read-only, but "#${path.node.id.name}" is updated via this expression.`, |
liuxingbaoyu
pushed a commit
to liuxingbaoyu/babel
that referenced
this pull request
Mar 5, 2024
* refactor: extract createPrivateMethodUpdateError * fix: check private method update after transform * fix: do not throw when a private name shadow decorated method * cleanup typings * review comments
Vylpes
pushed a commit
to Vylpes/random-bunny
that referenced
this pull request
Apr 10, 2024
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@babel/traverse](https://babel.dev/docs/en/next/babel-traverse) ([source](https://github.com/babel/babel)) | resolutions | patch | [`7.23.7` -> `7.23.9`](https://renovatebot.com/diffs/npm/@babel%2ftraverse/7.23.7/7.23.9) | --- ### Release Notes <details> <summary>babel/babel (@​babel/traverse)</summary> ### [`v7.23.9`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7239-2024-01-25) [Compare Source](babel/babel@v7.23.7...v7.23.9) ##### 🐛 Bug Fix - `babel-helper-transform-fixture-test-runner`, `babel-plugin-transform-function-name`, `babel-plugin-transform-modules-systemjs`, `babel-preset-env` - [#​16225](babel/babel#16225) fix: `systemjs` re-traverses helpers ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators` - [#​16226](babel/babel#16226) Improve decorated private method check ([@​JLHwung](https://github.com/JLHwung)) - `babel-plugin-proposal-decorators`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-runtime`, `babel-preset-env` - [#​16224](babel/babel#16224) Properly sort `core-js@3` imports ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) - `babel-traverse` - [#​15383](babel/babel#15383) fix: Don't throw in `getTypeAnnotation` when using TS+inference ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - Other - [#​16210](babel/babel#16210) \[eslint] Fix `no-use-before-define` for class ref in fields ([@​nicolo-ribaudo](https://github.com/nicolo-ribaudo)) ##### 🏠 Internal - `babel-core`, `babel-parser`, `babel-template` - [#​16222](babel/babel#16222) Migrate `eslint-parser` to cts ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-types` - [#​16213](babel/babel#16213) Remove `@babel/types` props that are not produced by the parser ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) ##### 🏃♀️ Performance - `babel-parser` - [#​16072](babel/babel#16072) perf: Improve parser performance for typescript ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) ##### 🔬 Output optimization - `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-destructuring-private`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-class-static-block`, `babel-plugin-transform-new-target`, `babel-plugin-transform-parameters`, `babel-plugin-transform-private-methods`, `babel-preset-env` - [#​16218](babel/babel#16218) Improve temporary variables for decorators ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) - `babel-helpers`, `babel-plugin-proposal-explicit-resource-management`, `babel-runtime-corejs2`, `babel-runtime-corejs3`, `babel-runtime` - [#​15959](babel/babel#15959) Improve output of `using` ([@​liuxingbaoyu](https://github.com/liuxingbaoyu)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=--> Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/142 Reviewed-by: Vylpes <ethan@vylpes.com> Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
github-actions
bot
added
the
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
label
Apr 20, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
PR: Bug Fix 🐛
A type of pull request used for our changelog categories
Spec: Decorators
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR we improve the decorated private method check in decorator transform. It now reuses the private name visitor factory from the class features plugin, which can handle the shadowed private name usage.
We also move the check after the decorator transform so that if the decorated method gets updated in its own function body, we can still detect such error.
This PR can be reviewed by commits.