es-check icon indicating copy to clipboard operation
es-check copied to clipboard

Nullish coalescing assignments cause SyntaxError

Open mischnic opened this issue 1 month ago • 4 comments

With this input file

reference.names[key] ??= cleanedKey;

es-check 9.5.0 fails with

$ pnpm es-check checkBrowser x.js --browserslistQuery="chrome 111"
info: ES-Check: checking 1 file...
error: ES-Check: there were 1 ES version matching errors.
info: 
      ES-Check Error:
      ----
      · erroring file: x.js at x.js:1:23
      · error: SyntaxError: Unexpected token (1:23)
      · see the printed err.stack below for context
      ----

      SyntaxError: Unexpected token (1:23)
    at pp$4.raise (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:3737:15)
    at pp$9.unexpected (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:776:10)
    at pp$5.parseExprAtomDefault (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:3076:10)
    at pp$5.parseExprAtom (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:3071:19)
    at pp$5.parseExprSubscripts (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2855:21)
    at pp$5.parseMaybeUnary (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2813:19)
    at pp$5.parseExprOp (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2766:43)
    at pp$5.parseExprOps (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2743:93)
    at pp$5.parseMaybeConditional (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2724:21)
    at pp$5.parseMaybeAssign (node_modules/.pnpm/[email protected]/node_modules/acorn/dist/acorn.js:2691:21)

but they are supported with Chrome 111: https://caniuse.com/mdn-javascript_operators_nullish_coalescing_assignment

mischnic avatar Dec 01 '25 09:12 mischnic