destructuring private fields with array pattern / object patte… (#10017)
* destructuring private fields with array pattern / object pattern * wip: new test cases * destrucuring and rest for private properties * test case for loose private-loose * add transform-desturcturing for exec * update test case * remove getPrototypeOf imports from get and set * wip: destructure super assignment * throw "Destructuring to a super field is not supported yet." * fix tests and fix assignment pattern * remove CallExpression from AssignmentPattern
This commit is contained in:
committed by
Nicolò Ribaudo
parent
7f47cb65d0
commit
d3fe22f0e1
@@ -0,0 +1,14 @@
|
||||
class Foo {
|
||||
#client
|
||||
|
||||
constructor(props) {
|
||||
;([this.#client] = props);
|
||||
}
|
||||
|
||||
getClient() {
|
||||
return this.#client;
|
||||
}
|
||||
}
|
||||
|
||||
const foo = new Foo(['bar']);
|
||||
expect(foo.getClient()).toBe('bar');
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
#client
|
||||
|
||||
constructor(props) {
|
||||
([this.#client] = props);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
var Foo = function Foo(props) {
|
||||
"use strict";
|
||||
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
|
||||
_client.set(this, {
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
|
||||
[babelHelpers.classPrivateFieldDestructureSet(this, _client).value] = props;
|
||||
};
|
||||
|
||||
var _client = new WeakMap();
|
||||
Reference in New Issue
Block a user