Logical assignment breaks on class static properties

Author: KyleDavidECreated Jan 15, 2026Updated Jan 27, 2026

I suspect this is because the variable flattener doesn't like how previous phases transpile local assignment in a way that creates a temporary variable.

Input:

javascript
class MyClass {}
console.log(() => {
  return (MyClass.myField ??= {});
});

with flags:

-O ADVANCED
--js in.js
--language_in ECMASCRIPT_NEXT
--language_out ECMASCRIPT_2020

Output:

javascript
class a{}console.log(()=>a.g??{});

Expected output:

javascript
// any of
class a{}console.log(()=>a.g??={});
var x;console.log(() => x??={});
var x;console.log(() => x??(x={}));
class a{};console.log(() => a.g??(a.g={}));