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
bc9b16c to
22e497f
Compare
8dacaf8 to
47de3f8
Compare
0c9a6dd to
5c8876d
Compare
47de3f8 to
ac59297
Compare
5c8876d to
53007ed
Compare
This was referenced Nov 15, 2024
11d4da4 to
9d7953d
Compare
66be587 to
6e392cf
Compare
9d7953d to
afc4792
Compare
This was referenced Nov 17, 2024
Merged
Member
Author
|
@Boshen How do I run monitor-oxc on this branch? (probably still some failures, but would help to see what they are) |
This was referenced Nov 22, 2024
Member
Author
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`;
}
}
```
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: