oxc/tasks
overlookmotel 0eadd9f6de fix(transformer/class-properties): create temp var for class where required (#7516)
Fix class properties transform to create a temp var for class when it's required.

Input:

```js
class C {
  static getSelf = () => this;
}
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Output:

```js
var _C;
class C {}
_C = C;
_defineProperty(C, "getSelf", () => _C);
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Previously, temp var wasn't used so code was `_defineProperty(C, "getSelf", () => C);`. `C` is altered later by `C = 123`, so `C2.getSelf()` returned `123`, instead of reference to the class.

The logic around when a temp var is required and when it's not, and when/where it's referenced is ridiculously complicated. So add some debug assert mechanisms to double-check the logic.
2024-12-03 07:46:04 +00:00
..
ast_tools chore(deps): update dependency rust to v1.83.0 (#7537) 2024-11-29 07:25:36 +00:00
benchmark refactor(linter): add capability of adding semantic data to module record (#7561) 2024-12-01 08:14:43 +00:00
common chore(doc): replace main/master to tag/commit to make the url always accessible (#7298) 2024-11-16 21:00:30 +08:00
compat_data chore(doc): replace main/master to tag/commit to make the url always accessible (#7298) 2024-11-16 21:00:30 +08:00
coverage refactor(syntax): remove ModuleRecord::export_default (#7578) 2024-12-02 09:17:57 +00:00
javascript_globals feat(linter)!: sync sindresorhus/globals; removed Object.prototype properties from builtin and es* globals (#6991) 2024-10-29 04:13:20 +00:00
lint_rules fix(tasks/lint_rules): map prefix node to n (#7397) 2024-11-21 13:58:53 +00:00
minsize chore(minifier): temporary remove try_fold_if_block_one and try_fold_if_one_child (#7536) 2024-11-29 05:05:07 +00:00
prettier_conformance chore(tasks): Update prettier_conformance task (#7500) 2024-11-27 08:40:43 +00:00
rulegen fix(rulegen): update lint rule template (#7502) 2024-11-27 17:40:38 +08:00
transform_checker chore: Rust v1.83.0 changes (#7535) 2024-11-29 11:59:45 +08:00
transform_conformance fix(transformer/class-properties): create temp var for class where required (#7516) 2024-12-03 07:46:04 +00:00
website docs(linter): fix config example headings (#7562) 2024-12-01 16:31:22 +08:00