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`;
}
}
```
Add a NodeJS script which amends Babel's fixtures in place to remove transform plugins which we don't support from `options.json` files. Where options are changed from the original, the script runs Babel transform with the new options to regenerate the fixture `output.js` files.
Currently limited to transforming the fixtures for `babel-plugin-transform-class-properties` transform, but we can also enable it for other plugins if we wish in future, to get additional test coverage.
Fixed a bunch of semantic errors by removing moving binding logic 😢. This plugin constructs a complex `for-await` replacement so that I wrongly move to an incorrect scope.
close: #7338close: #7344
The `SymbolFlags::Export` is Initially used to solve `ExportSpecifier` that is not `IdentifierReference` that causes we cannot determine whether a Binding is not used everywhere by `Semantic`.
Since #3820 this problem is solved, so we don't need `SymbolFlags::Export` no longer. Also, removing this can help us easier to pass the `Semantic` check in `Transformer`
Add `--debug` command line option for transformer conformance runner, same as for `cargo coverage`. It prints the paths of test fixtures before running them.
Currently the website links to main which is subject to change without
an update to the website. This updates the website to link to the
specific commit that was used when the website was published.
Feel free to cleanup anything in this PR.
Fix due to this plugin transforming the async method and async arrow function, it caused arguments no longer point the original function.
For example:
Before
```js
class Cls {
async method() {
() => {
console.log(arguments)
}
}
}
```
After:
```js
class Cls {
method() {
var _arguments = arguments;
return babelHelpers.asyncToGenerator(function* () {
() => {
console.log(_arguments);
};
})();
}
}
```
In this way, the `_arguments` is its original function's arguments
### For performance regression
It seems we need to check the IdentifierReference and BindingIdentifier if it's an `arguments`, that causes a significant regression, we may need a cheap way to do checking
I mentioned this clippy issue in the discord help channel. The problem
seems to be related to using the stable rust toolchain, but when I
switched to version `1.81.0`, the issue was resolved.
However, some of the clippy suggestions might still be worth considering
and could be adopted.
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Firstly, a massive thanks to @alisnic for starting this (incredibly complicated) lint rule in https://github.com/oxc-project/oxc/pull/2637 !
still a draft. current state:
3x false positives (all todo with refs)
3x false negatives (TS will catch these
13x false negatvies todo with refs
1x false negative TODO
closes #2637
relates to #2174