Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[parser] Disallow static fields named
constructor
(#10461)
* Disallow static fields named `constructor` in a class - Disallowed static fields named `constructor` in a class (previously only non-static were disallowed) - Updated the text for the error for one consolidated warning, for both static and non-static fields - Added a test - Updated an existing test in the `flow` test suite of the parser to reflect the parse error. Strangely, the test used to pass and started failing when inlining the `isNonstaticConstructor` method, without any changes. In that test, `constructor` was a field, so in theory it should never have passed. Would appreciate some feedback on this, as I'm not 100% sure if this is somehow related to Flow * Update test262 whitelist * Add comment and fix && operator
- Loading branch information
1 parent
87dc201
commit 9c1ad0a
Showing
8 changed files
with
18 additions
and
182 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
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor-2/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"throws": "Classes may not have a non-static field named 'constructor' (2:2)", | ||
"throws": "Classes may not have a field named 'constructor' (2:2)", | ||
"plugins": ["classProperties"] | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/babel-parser/test/fixtures/experimental/class-properties/no-ctor/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"throws": "Classes may not have a non-static field named 'constructor' (2:2)", | ||
"throws": "Classes may not have a field named 'constructor' (2:2)", | ||
"plugins": ["classProperties"] | ||
} |
3 changes: 3 additions & 0 deletions
3
...arser/test/fixtures/experimental/class-properties/static-field-named-constructor/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,3 @@ | ||
class Foo { | ||
static constructor; | ||
} |
4 changes: 4 additions & 0 deletions
4
...r/test/fixtures/experimental/class-properties/static-field-named-constructor/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,4 @@ | ||
{ | ||
"throws": "Classes may not have a field named 'constructor' (2:11)", | ||
"plugins": ["classProperties"] | ||
} |
1 change: 1 addition & 0 deletions
1
...arser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"throws": "Classes may not have a field named 'constructor' (2:2)", | ||
"plugins": ["jsx", "flow", "classProperties"] | ||
} |
169 changes: 0 additions & 169 deletions
169
...parser/test/fixtures/flow/classes/constructor-override-with-class-prop-plugin/output.json
This file was deleted.
Oops, something went wrong.
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