feat(transformer): class properties transform#7011
Merged
graphite-app[bot] merged 1 commit intomainfrom Nov 25, 2024
Merged
Conversation
Contributor
Your org has enabled the Graphite merge queue for merging into mainAdd the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
Member
Author
0eb3ad7 to
906e8fd
Compare
CodSpeed Performance ReportMerging #7011 will degrade performances by 19.21%Comparing Summary
Benchmarks breakdown
|
7b2ad83 to
1f4eef9
Compare
366cc8f to
65400df
Compare
96a98ba to
2a57a66
Compare
5663771 to
0c69972
Compare
0c69972 to
3970e03
Compare
Member
Author
|
Yes, I hope there's a better solution. I just wanted some working tests while I'm building the transform. |
Boshen
pushed a commit
that referenced
this pull request
Oct 31, 2024
Skeleton of class properties transform. #7011 contains WIP implementation.
c71dda8 to
78b7bed
Compare
7f0dd2c to
eeeccba
Compare
3629c39 to
139ac62
Compare
3d4a890 to
8d1ea70
Compare
139ac62 to
c986cf7
Compare
8d1ea70 to
b4c5bea
Compare
303e42d to
11d7479
Compare
b4c5bea to
8248e29
Compare
84b9b88 to
7a52127
Compare
Member
Author
7a52127 to
f8bcbcc
Compare
8248e29 to
2c34991
Compare
f8bcbcc to
5247d52
Compare
2c34991 to
25f2a20
Compare
5247d52 to
1fdf61f
Compare
Member
Merge activity
|
Add class properties transform.
Implementation is incomplete. Notable missing parts:
* Scopes are not updated where property initializers move from class body into class constructor / `_super` function.
* Does not handle binding shadowing problems when property initializers move from class body into class constructor.
* `this` and references to class name in static property initializers need to be transformed to point to a temp var.
* Not all usages of private properties are supported (see below).
* Code which is moved to outside of class body is not transformed by other transforms for class declarations (works OK for class expressions). This includes static property initializers, static blocks, and computed property/method keys.
* Only basic checks for whether computed property/method keys may have side effects.
* Numerous other small issues noted in TODO comments through the code.
### Private properties
Currently does not handle the following usages of private properties:
```js
class Class {
#prop;
static #static;
method() {
object?.#prop;
object?.#prop();
[object.#prop] = [1];
({x: object.#prop} = {x: 1});
object.#prop`xyz`;
object?.#static;
object?.#static();
[object.#static] = [1];
({x: object.#static} = {x: 1});
object.#static`xyz`;
}
}
```
25f2a20 to
3b2a347
Compare
1fdf61f to
9778298
Compare
Base automatically changed from
11-04-test_transformer_script_to_amend_babel_fixtures
to
main
November 25, 2024 10:28
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Add class properties transform.
Implementation is incomplete. Notable missing parts:
_superfunction.thisand references to class name in static property initializers need to be transformed to point to a temp var.Private properties
Currently does not handle the following usages of private properties: