Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 馃毀
- Loading branch information
Showing
49 changed files
with
515 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...l-class-properties/test/fixtures/private-loose/destructuring-array-pattern-static/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
;([Foo.#client] = props); | ||
} | ||
|
||
getClient() { | ||
return Foo.#client; | ||
} | ||
} | ||
|
||
const foo = new Foo(['bar']); | ||
expect(foo.getClient()).toBe('bar'); |
7 changes: 7 additions & 0 deletions
7
...-class-properties/test/fixtures/private-loose/destructuring-array-pattern-static/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
([Foo.#client] = props); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...class-properties/test/fixtures/private-loose/destructuring-array-pattern-static/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var _client = babelHelpers.classPrivateFieldLooseKey("client"); | ||
|
||
var Foo = function Foo(props) { | ||
"use strict"; | ||
|
||
babelHelpers.classCallCheck(this, Foo); | ||
[babelHelpers.classPrivateFieldLooseBase(Foo, _client)[_client]] = props; | ||
}; | ||
|
||
Object.defineProperty(Foo, _client, { | ||
writable: true, | ||
value: void 0 | ||
}); |
14 changes: 14 additions & 0 deletions
14
...-class-properties/test/fixtures/private-loose/destructuring-object-pattern-static/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
;({ client: Foo.#client } = props) | ||
} | ||
|
||
getClient() { | ||
return Foo.#client; | ||
} | ||
} | ||
|
||
const foo = new Foo({ client: 'bar' }); | ||
expect(foo.getClient()).toBe('bar'); |
7 changes: 7 additions & 0 deletions
7
...class-properties/test/fixtures/private-loose/destructuring-object-pattern-static/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
({ client: Foo.#client } = props) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...lass-properties/test/fixtures/private-loose/destructuring-object-pattern-static/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var _client = babelHelpers.classPrivateFieldLooseKey("client"); | ||
|
||
var Foo = function Foo(props) { | ||
"use strict"; | ||
|
||
babelHelpers.classCallCheck(this, Foo); | ||
({ | ||
client: babelHelpers.classPrivateFieldLooseBase(Foo, _client)[_client] | ||
} = props); | ||
}; | ||
|
||
Object.defineProperty(Foo, _client, { | ||
writable: true, | ||
value: void 0 | ||
}); |
14 changes: 14 additions & 0 deletions
14
...roposal-class-properties/test/fixtures/private/destructuring-array-pattern-static/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
;([Foo.#client] = props); | ||
} | ||
|
||
getClient() { | ||
return Foo.#client; | ||
} | ||
} | ||
|
||
const foo = new Foo(['bar']); | ||
expect(foo.getClient()).toBe('bar'); |
7 changes: 7 additions & 0 deletions
7
...oposal-class-properties/test/fixtures/private/destructuring-array-pattern-static/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
([Foo.#client] = props); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...posal-class-properties/test/fixtures/private/destructuring-array-pattern-static/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var Foo = function Foo(props) { | ||
"use strict"; | ||
|
||
babelHelpers.classCallCheck(this, Foo); | ||
[babelHelpers.classStaticPrivateFieldDestructureSet(Foo, Foo, _client).value] = props; | ||
}; | ||
|
||
var _client = { | ||
writable: true, | ||
value: void 0 | ||
}; |
14 changes: 14 additions & 0 deletions
14
...oposal-class-properties/test/fixtures/private/destructuring-object-pattern-static/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Foo { | ||
static #client | ||
|
||
constructor(props) { | ||
;({ client: Foo.#client } = props) | ||
} | ||
|
||
getClient() { | ||
return Foo.#client; | ||
} | ||
} | ||
|
||
const foo = new Foo({ client: 'bar' }); | ||
expect(foo.getClient()).toBe('bar'); |
Oops, something went wrong.