Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Aug 21, 2021
1 parent d743bc8 commit 94215e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/babel-parser/src/plugins/typescript/index.js
Expand Up @@ -2393,18 +2393,19 @@ export default (superClass: Class<Parser>): Class<Parser> =>
member: any,
state: N.ParseClassMemberState,
): void {
const invalidModifersForStaticBlocks = [
const modifiers = [
"declare",
"private",
"public",
"protected",
"override",
"abstract",
"readonly",
"static",
];
this.tsParseModifiers(
member,
invalidModifersForStaticBlocks.concat(["static"]),
modifiers,
/* disallowedModifiers */ undefined,
/* errorTemplate */ undefined,
/* stopOnStartOfClassStaticBlock */ true,
Expand All @@ -2414,7 +2415,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (this.tsIsStartOfStaticBlocks()) {
this.next(); // eat "static"
this.next(); // eat "{"
if (this.tsHasSomeModifiers(member, invalidModifersForStaticBlocks)) {
if (this.tsHasSomeModifiers(member, modifiers)) {
this.raise(this.state.pos, TSErrors.StaticBlockCannotHaveModifier);
}
this.parseClassStaticBlock(classBody, ((member: any): N.StaticBlock));
Expand Down
@@ -1,6 +1,9 @@
{
"type": "File",
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"errors": [
"SyntaxError: Static class blocks cannot have any modifier. (2:18)"
],
"program": {
"type": "Program",
"start":0,"end":32,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
Expand Down

0 comments on commit 94215e2

Please sign in to comment.