mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(ast): support FormalParameter.override (#2577)
This [code](https://oxc-project.github.io/oxc/playground/?code=3YCAAIC1gICAgICAgICxG4jI43W9aqTWr3WzyA0TqSOjtB34F78iblvTQruFcqR6BUbbiLtWhj5rEL0NnFkDs4pF3dHiw39X7YCA) can't be represented in the current OXC AST: ```ts class Foo { constructor(override bar: string) {} } ```
This commit is contained in:
parent
78f30bc2db
commit
258b9b1c14
6 changed files with 13 additions and 2 deletions
|
|
@ -1799,6 +1799,7 @@ pub struct FormalParameter<'a> {
|
|||
pub pattern: BindingPattern<'a>,
|
||||
pub accessibility: Option<TSAccessibility>,
|
||||
pub readonly: bool,
|
||||
pub r#override: bool,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -796,9 +796,10 @@ impl<'a> AstBuilder<'a> {
|
|||
pattern: BindingPattern<'a>,
|
||||
accessibility: Option<TSAccessibility>,
|
||||
readonly: bool,
|
||||
r#override: bool,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> FormalParameter<'a> {
|
||||
FormalParameter { span, pattern, accessibility, readonly, decorators }
|
||||
FormalParameter { span, pattern, accessibility, readonly, r#override, decorators }
|
||||
}
|
||||
|
||||
pub fn ts_this_parameter(
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ impl<'a> ParserImpl<'a> {
|
|||
pattern,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
AstBuilder::new_vec(&self.ast),
|
||||
);
|
||||
let params = self.ast.formal_parameters(
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ impl<'a> SeparatedList<'a> for FormalParameterList<'a> {
|
|||
let modifiers = p.parse_class_element_modifiers(true);
|
||||
let accessibility = modifiers.accessibility();
|
||||
let readonly = modifiers.readonly();
|
||||
let r#override = modifiers.r#override();
|
||||
|
||||
match p.cur_kind() {
|
||||
Kind::This if p.ts_enabled() => {
|
||||
|
|
@ -278,6 +279,7 @@ impl<'a> SeparatedList<'a> for FormalParameterList<'a> {
|
|||
pattern,
|
||||
accessibility,
|
||||
readonly,
|
||||
r#override,
|
||||
decorators,
|
||||
);
|
||||
self.elements.push(formal_parameter);
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ enum Version {
|
|||
#[default]
|
||||
Year202305,
|
||||
}
|
||||
|
||||
impl Version {
|
||||
fn is_legacy(self) -> bool {
|
||||
matches!(self, Self::Legacy)
|
||||
|
|
@ -479,6 +480,7 @@ impl<'a> Decorators<'a> {
|
|||
),
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
self.ast.new_vec(),
|
||||
)),
|
||||
None,
|
||||
|
|
@ -555,6 +557,7 @@ impl<'a> Decorators<'a> {
|
|||
),
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
self.ast.new_vec(),
|
||||
))
|
||||
} else {
|
||||
|
|
@ -909,6 +912,7 @@ impl<'a> Decorators<'a> {
|
|||
),
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
self.ast.new_vec(),
|
||||
));
|
||||
let private_field = self.ast.private_field(
|
||||
|
|
@ -959,6 +963,7 @@ impl<'a> Decorators<'a> {
|
|||
),
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
self.ast.new_vec(),
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ impl<'a> TypeScript<'a> {
|
|||
let mut params = self.ast.new_vec();
|
||||
|
||||
// ((Foo) => {
|
||||
params.push(self.ast.formal_parameter(SPAN, id, None, false, self.ast.new_vec()));
|
||||
params.push(self.ast.formal_parameter(SPAN, id, None, false, false, self.ast.new_vec()));
|
||||
|
||||
let params = self.ast.formal_parameters(
|
||||
SPAN,
|
||||
|
|
@ -680,6 +680,7 @@ impl<'a> TypeScript<'a> {
|
|||
),
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
self.ast.new_vec(),
|
||||
)),
|
||||
None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue