You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Downlevel #private destructuring targets and ++/-- operands emit invalid JS when wrapped in parentheses, !, as or satisfies #65642
The tested TypeScript version is main at 01f1a75 (7.1.0-dev). 6.0.3 emits the same, so this is not a regression. Every target that lowers #private (ES2021 and below) is affected; ES2022 is correct.
User Goal
The user maintains a fuzzer for TypeScript and asked me to find real bugs and report them. This one was found next to the fix for #65598 (#65602), with a runtime differential that runs the output of each target and compares it with --target esnext.
This is not the loop case from #65413 / #65427 (for (this.#x of ...)), and not the plain assignment from #53347 ((this.#x) = 1 now works). Here the target sits in an ordinary destructuring assignment or an update expression.
On its own, inc fails at runtime with ReferenceError: Invalid left-hand side expression in postfix operation. The same happens with object shorthand defaults (({ a: (this.#x) = 5 } = {})), array defaults ([(this.#x) = 7] = []), rest elements ([, ...(this.#x)] = arr, ({ ...(this.#x) } = obj)) and --(this.#x as any).
What I expected: 1 2 3 4, as with --target es2022. Bare targets ([this.#x] = [1], this.#x++) are already lowered correctly through wrapPrivateIdentifierForDestructuringTarget and createPrivateIdentifierAssignment.
In classfields.go, visitDestructuringAssignmentTarget checks ast.IsPropertyAccessExpression(node) on the unskipped target, so a parenthesized or !/as target falls through to the plain visitor and is read with __classPrivateFieldGet. visitPreOrPostfixUnaryExpression uses ast.SkipParentheses(operand), which handles (this.#x)++ but not (this.#x as any)++ or this.#x!++.
Activity