Skip to content

Commit a740f3f

Browse files
committed
fix(semantic): allow arguments/eval as argument name inside TSMethodSignature (#12289)
1 parent 3f33e8c commit a740f3f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

crates/oxc_semantic/src/checker/javascript.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +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
120121
// declare function g({eval, arguments}: {eval: number, arguments: number}): number; // Error
121122
// declare function h([eval, arguments]: [number, number]): number; // Error
122123
let is_declare_function = |kind: &AstKind| {
@@ -129,11 +130,9 @@ pub fn check_binding_identifier(ident: &BindingIdentifier, ctx: &SemanticBuilder
129130
AstKind::Function(func) => matches!(func.r#type, FunctionType::TSDeclareFunction),
130131
AstKind::FormalParameter(_) => {
131132
is_declare_function(&ctx.nodes.parent_kind(parent.id()))
132-
|| ctx
133-
.nodes
134-
.ancestor_kinds(parent.id())
135-
.nth(1)
136-
.is_some_and(|node| matches!(node, AstKind::TSFunctionType(_)))
133+
|| ctx.nodes.ancestor_kinds(parent.id()).nth(1).is_some_and(|node| {
134+
matches!(node, AstKind::TSFunctionType(_) | AstKind::TSMethodSignature(_))
135+
})
137136
}
138137
AstKind::BindingRestElement(_) => {
139138
let grand_parent = ctx.nodes.parent_node(parent.id());
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
type K = (arguments: any[]) => void;
2+
3+
interface Foo {
4+
bar(arguments: any[]): void;
5+
}

0 commit comments

Comments
 (0)