oxc/tasks/transform_conformance/src
overlookmotel 9778298fdb feat(transformer): class properties transform (#7011)
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`;
  }
}
```
2024-11-25 10:24:20 +00:00
..
constants.rs feat(transformer): class properties transform (#7011) 2024-11-25 10:24:20 +00:00
driver.rs feat(transformer)!: change API to take a &TransformOptions instead of TransformOptions (#7213) 2024-11-09 06:01:13 +00:00
exec.rs refactor(transform_conformance): clean up some code (#7354) 2024-11-19 09:15:14 +00:00
lib.rs test(transformer): add --debug option to transform conformance (#7400) 2024-11-22 02:23:10 +00:00
main.rs test(transformer): add --debug option to transform conformance (#7400) 2024-11-22 02:23:10 +00:00
test_case.rs refactor(transformer)!: return String as error instead of OxcDiagnostic (#7424) 2024-11-22 16:22:49 +00:00