Skip to content

Error for destructuring parameter with default value #17

Description

@saviola777

Hello,

thanks for this great library. Here's a (potential) bug I have found:

function mwe({ var1 = true } = { var1: false }) {
    console.log(var1);
}

Trying to run the reflector on this function gives me the error

VM1240:5 Uncaught SyntaxError: Unexpected token =
    at new Function (<anonymous>)
    at betterEval (parameter-parser.js:31)
    at ParameterParser.pushBuffer (parameter-parser.js:190)
    at ParameterParser.parse (parameter-parser.js:140)
    at reflector (index.js:9)
    […]

It is worth noting that function mwe({ var1 = true }) works and gives the correct result (destructuring argument with default value for var1), while function mwe({ var1 } = { var1: false }) does not cause an error but does not produce the expected result either (no destructuring parameter detected).

I'm not too familar with the JS/ECMA specifications, so if this is syntax you do not plan to support then sorry for bringing it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions