mihaip / react-closure-compiler

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

Deal with static methods in mixins #47

Closed arv closed 5 years ago

arv commented 5 years ago

When a mixin has a static method that method gets copied into the mixin target dynamically. Therefore we need to declare the type of that method. For example, for:

class Mixin extends React.Component {
    /** @param {number} x */
    static method(x) {}
}
ReactSupport.declareMixin(Mixin);
class Comp extends React.Component {}
ReactSupport.mixin(Comp, Mixin);

we generate:

/** @type {function(number)} */
Comp.method;