Skip to content

Commit 1bfd44f

Browse files
committed
fix(semantic): allow arguments/eval as spread argument name inside TSMethodSignature, TSFunctionType (#12290)
1 parent a740f3f commit 1bfd44f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-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
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
type K = (arguments: any[]) => void;
2+
type K2 = (...arguments: any[]) => void;
23

34
interface Foo {
45
bar(arguments: any[]): void;
6+
bar2(...arguments: any[]): void;
57
}

0 commit comments

Comments
 (0)