Class static private field destructure set (#12917)

* fix: support static private field destructure set ([C.#p] = [0])

* 🚧

* fix: add compatibility warning for older @babel/helper versions

* refactor: extract common routines among classPrivateFiled helpers

* More 🚧
This commit is contained in:
Huáng Jùnliàng
2021-03-03 16:38:16 -05:00
committed by GitHub
parent 70c77e550c
commit bdb207cb75
49 changed files with 520 additions and 134 deletions

View File

@@ -0,0 +1,10 @@
class A {
static #method() {}
run() {
expect(() => A.#method = 2).toThrow(TypeError);
expect(() => ([A.#method] = [2])).toThrow(TypeError);
}
}

View File

@@ -0,0 +1,8 @@
class A {
static #method() {}
run() {
A.#method = 2;
([A.#method] = [2]);
}
}

View File

@@ -0,0 +1,9 @@
class A {
run() {
babelHelpers.classStaticPrivateMethodSet(A, A, _method, 2);
[babelHelpers.classStaticPrivateFieldDestructureSet(A, A, _method).value] = [2];
}
}
var _method = function _method() {};