Skip to content

Commit ea6e978

Browse files
committed
fix(semantic): allow arguments as spread argument name inside TSMethodSignature, TSFunctionType
1 parent 8e1e8c5 commit ea6e978

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

crates/oxc_semantic/src/checker/javascript.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn check_binding_identifier(ident: &BindingIdentifier, ctx: &SemanticBuilder
117117
// declare function f(...eval): number; // OK
118118
// declare function f(...arguments): number; // OK
119119
// type K = (arguments: any[]) => void; // OK
120-
// interface Foo { bar(arguments: any[]): void; } // OK
120+
// interface Foo { bar(arguments: any[]): void; baz(...arguments: any[]): void; } // OK
121121
// declare function g({eval, arguments}: {eval: number, arguments: number}): number; // Error
122122
// declare function h([eval, arguments]: [number, number]): number; // Error
123123
let is_declare_function = |kind: &AstKind| {
@@ -136,8 +136,15 @@ pub fn check_binding_identifier(ident: &BindingIdentifier, ctx: &SemanticBuilder
136136
}
137137
AstKind::BindingRestElement(_) => {
138138
let grand_parent = ctx.nodes.parent_node(parent.id());
139-
matches!(grand_parent.kind(), AstKind::FormalParameters(_))
140-
&& is_declare_function(&ctx.nodes.parent_kind(grand_parent.id()))
139+
matches!(grand_parent.kind(), AstKind::FormalParameters(_)) && {
140+
let great_grand_parent = ctx.nodes.parent_kind(grand_parent.id());
141+
142+
is_declare_function(&great_grand_parent)
143+
|| matches!(
144+
great_grand_parent,
145+
AstKind::TSMethodSignature(_) | AstKind::TSFunctionType(_)
146+
)
147+
}
141148
}
142149
_ => false,
143150
};

0 commit comments

Comments
 (0)