mihaip / react-closure-compiler

Tooling to teach Closure Compiler about React
Apache License 2.0
100 stars 14 forks source link

Handle destructuring when transpiling to ES5 #29

Open mihaip opened 6 years ago

mihaip commented 6 years ago

A component method of the form:

/**
  * @param {SomeType} type
  * @return {SomeType}
  */
someMethod({
        destructuredField1,
        destructuredField2,
    }) {
    ...
    return 1;
},

Produces a warning:

ERROR - Missing return statement. Function expected to return SomeType.
  someMethod({

I believe this is because we copy the arguments (including the arguments) in the generated interface for the component, and then that gets transpiled down to code in the function body.

google/closure-compiler#3004 may be related