Huáng Jùnliàng bdb207cb75
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 🚧
2021-03-03 16:38:16 -05:00

23 lines
432 B
JavaScript

class Cl {
#privateField = 0;
counter = 0;
get #privateFieldValue() {
return this.#privateField;
}
get self() {
this.counter++;
return this;
}
constructor() {
expect(() => this.self.#privateFieldValue = 1).toThrow(TypeError);
expect(this.counter).toBe(1);
expect(() => ([this.self.#privateFieldValue] = [1])).toThrow(TypeError);
expect(this.counter).toBe(2);
}
}
const cl = new Cl();