mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
fix(parser): unexpected ts type annotation in get/set (#1942)
fix: https://github.com/oxc-project/oxc/issues/1939
This commit is contained in:
parent
b97a536df7
commit
b50c5ec623
4 changed files with 29 additions and 1 deletions
|
|
@ -294,6 +294,10 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
Ok(definition)
|
||||
} else {
|
||||
// getter and setter has no ts type annotation
|
||||
if !kind.is_method() {
|
||||
return Err(self.unexpected());
|
||||
}
|
||||
let definition = self.parse_class_property_definition(
|
||||
span,
|
||||
key,
|
||||
|
|
|
|||
5
tasks/coverage/misc/fail/oxc-1942-1.ts
Normal file
5
tasks/coverage/misc/fail/oxc-1942-1.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Foo {
|
||||
get x: () => {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
3
tasks/coverage/misc/fail/oxc-1942-2.ts
Normal file
3
tasks/coverage/misc/fail/oxc-1942-2.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class Foo {
|
||||
set x: (v: number) => {}
|
||||
}
|
||||
|
|
@ -1,12 +1,28 @@
|
|||
parser_misc Summary:
|
||||
AST Parsed : 9/9 (100.00%)
|
||||
Positive Passed: 9/9 (100.00%)
|
||||
Negative Passed: 3/3 (100.00%)
|
||||
Negative Passed: 5/5 (100.00%)
|
||||
× Unexpected token
|
||||
╭─[fail/oxc-169.js:1:1]
|
||||
1 │ 1<(V=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V=uIV=82<<t-j0<(V=$<LBI<(V=ut<I<(V=$<LBI<(V<II>
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
╭─[fail/oxc-1942-1.ts:1:1]
|
||||
1 │ class Foo {
|
||||
2 │ get x: () => {
|
||||
· ─
|
||||
3 │ return 5;
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
╭─[fail/oxc-1942-2.ts:1:1]
|
||||
1 │ class Foo {
|
||||
2 │ set x: (v: number) => {}
|
||||
· ─
|
||||
3 │ }
|
||||
╰────
|
||||
|
||||
× Empty parenthesized expression
|
||||
╭─[fail/oxc-232.js:1:1]
|
||||
1 │ x = (/* a */)
|
||||
|
|
|
|||
Loading…
Reference in a new issue