Invalid output resulting in ReferenceErrors with plugin-proposal-optional-chaining #12026
Closed
1 task
Labels
i: bug
i: needs triage
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
Bug Report
Current behavior
When a nested optional chaining expression is found inside a parameter position (a parameter default value, or default value inside an object or array destructuring), a
var
declaration is added to the function body. That variable declaration is not in effect when evaluating parameter default values and causes aReferenceError
in strict mode when the function is called.To repro, you can use the Babel CLI to compile the code below and run it with Node:
babel test.js | node
. Error output:Input Code
Output Code
Expected behavior
Should not throw a
ReferenceError
, should logundefined
to the console.Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
babel.config.js
See REPL link above, or just add the
plugin-proposal-optional-chaining
(doesn't matter whether loose or not, happens in both modes)Environment
The text was updated successfully, but these errors were encountered: