Files
oxc-project__oxc/tasks/coverage/misc/pass/oxc-22157.js
camc314 9fa2122cef fix(parser): parse array computed class keys (#22159)
Fixes parser recovery for class computed property names whose expression starts with an array literal, such as `class C { [[]]() {} }`.

The TypeScript index-signature lookahead previously treated a nested `[` after the opening computed-name bracket as an unambiguous index signature. That caused valid class computed keys containing array literals to be parsed through the wrong branch and rejected.

This changes the lookahead so only `...` remains an early unambiguous index-signature signal, allowing nested arrays and other assignment expressions to parse as computed property names.

fixes: #22157
2026-05-05 20:46:22 +00:00

14 lines
131 B
JavaScript

class C {
[[]]() {}
[[1]]() {}
[[]] = 1;
}
const o = { [[]]() {} };
const x = [];
class x2 {
[[...x]]() {}
[.1]() {}
}