mihaip / react-closure-compiler

Tooling to teach Closure Compiler about React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle destructuring when transpiling to ES5

mihaip opened this issue · comments

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