mihaip / react-closure-compiler

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

Declare optional astract mixin methods on target #41

Closed arv closed 5 years ago

arv commented 5 years ago

When a mixin has an optional abstract method we need to tell the class about it.

class Mixin extends React.Component {}
ReactSupport.declareMixin(Mixin);
/**
 * @param {a} p
 * @return {b}
 */
Mixin.optionalAbstract;
class Comp extends React.Component {}
ReactSupport.mixin(Comp, Mixin);

we generate code that looks like:

/** @type {(function(a): b)|undefined} */
Comp.prototype.optionalAbstract;

Without this we end up getting a Unexpected errors: JSC_INTERFACE_METHOD_NOT_IMPLEMENTED. property optionalAbstract on interface MixinInterface is not implemented by type Comp