Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[parser] Parse only modifiers of actual methods (#10594)
* Parse only modifiers of actual methods * Throw question token if is used before the real name
- Loading branch information
1 parent
01927ba
commit b6ef968
Showing
5 changed files
with
237 additions
and
0 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
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/typescript/class/async-named-properties/input.ts
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 @@ | ||
class A { | ||
async?(): void | ||
async?: boolean | ||
} |
221 changes: 221 additions & 0 deletions
221
packages/babel-parser/test/fixtures/typescript/class/async-named-properties/output.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,221 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 46, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 1 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 46, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 1 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ClassDeclaration", | ||
"start": 0, | ||
"end": 46, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 1 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 6, | ||
"end": 7, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 6 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 7 | ||
}, | ||
"identifierName": "A" | ||
}, | ||
"name": "A" | ||
}, | ||
"superClass": null, | ||
"body": { | ||
"type": "ClassBody", | ||
"start": 8, | ||
"end": 46, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 8 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 1 | ||
} | ||
}, | ||
"body": [ | ||
{ | ||
"type": "TSDeclareMethod", | ||
"start": 12, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 16 | ||
} | ||
}, | ||
"static": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start": 12, | ||
"end": 17, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 7 | ||
}, | ||
"identifierName": "async" | ||
}, | ||
"name": "async" | ||
}, | ||
"computed": false, | ||
"optional": true, | ||
"kind": "method", | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"returnType": { | ||
"type": "TSTypeAnnotation", | ||
"start": 20, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 16 | ||
} | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSVoidKeyword", | ||
"start": 22, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 16 | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ClassProperty", | ||
"start": 29, | ||
"end": 44, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 17 | ||
} | ||
}, | ||
"static": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start": 29, | ||
"end": 34, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 7 | ||
}, | ||
"identifierName": "async" | ||
}, | ||
"name": "async" | ||
}, | ||
"computed": false, | ||
"optional": true, | ||
"typeAnnotation": { | ||
"type": "TSTypeAnnotation", | ||
"start": 35, | ||
"end": 44, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 8 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 17 | ||
} | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSBooleanKeyword", | ||
"start": 37, | ||
"end": 44, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 17 | ||
} | ||
} | ||
} | ||
}, | ||
"value": null | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-parser/test/fixtures/typescript/class/optional-async-error/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,4 @@ | ||
class B { } | ||
class A extends B { | ||
async? method(val: string): Promise<void>; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/typescript/class/optional-async-error/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,3 @@ | ||
{ | ||
"throws": "Unexpected token (3:9)" | ||
} |