Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix classNameTDZError in computed prototype methods with class fields (…
…#11068) * Draft fix for TDZError in computed prototype methods * Added tests for loose:false and also extracted handleClassTDZ * Added state parameter to handleClassTDZ function * Extracted the state object to a variable * Added helper comments for environmentVisitor * Added else condition to traverse computed Path * Cached computed path key into a variable
- Loading branch information
1 parent
157bb6e
commit 3fc904e
Showing
8 changed files
with
79 additions
and
25 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
6 changes: 6 additions & 0 deletions
6
...te-class-features-plugin/test/fixtures/tdz-error-computed-prototypes/loose-false/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,6 @@ | ||
class Foo { | ||
static nickname = 'Tom'; | ||
['HELLO']() { | ||
console.log('>>>>', Foo); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...lass-features-plugin/test/fixtures/tdz-error-computed-prototypes/loose-false/options.json
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,10 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"proposal-class-properties", | ||
{ | ||
"loose": false | ||
} | ||
] | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...e-class-features-plugin/test/fixtures/tdz-error-computed-prototypes/loose-false/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,10 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
class Foo { | ||
['HELLO']() { | ||
console.log('>>>>', Foo); | ||
} | ||
|
||
} | ||
|
||
_defineProperty(Foo, "nickname", 'Tom'); |
6 changes: 6 additions & 0 deletions
6
...ate-class-features-plugin/test/fixtures/tdz-error-computed-prototypes/loose-true/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,6 @@ | ||
class Foo { | ||
static nickname = 'Tom'; | ||
['HELLO']() { | ||
console.log('>>>>', Foo); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...class-features-plugin/test/fixtures/tdz-error-computed-prototypes/loose-true/options.json
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,10 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"proposal-class-properties", | ||
{ | ||
"loose": true | ||
} | ||
] | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
...te-class-features-plugin/test/fixtures/tdz-error-computed-prototypes/loose-true/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,8 @@ | ||
class Foo { | ||
['HELLO']() { | ||
console.log('>>>>', Foo); | ||
} | ||
|
||
} | ||
|
||
Foo.nickname = 'Tom'; |
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