google / google/closure-compiler
Support extending a mixin application expression directly
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
@azakus has talked to some folks about this offline but I wanted to make an issue to link to / track.
Currently to support ES6 class mixin, one must do something like:
```js
// declaration
/**
* @interface
*/
function TimedInterface(){}
/** @type {number} */
TimedInterface.prototype.time;
/**
* @template T
* @param {T} mixin ES6 class expression mixin to wrap
*/
function Timed(superclass) {
return class extends superclass {
constructor {
/** @type {number} */
this.time = 0;
}
}
};
// use
/**
* @implements {TimedInterface}
* @extends {Foo}
*/
const TimedFoo = Timed(Foo);
class Bar extends TimedFoo {};
```
There are two suboptimal parts to this. The first is that we need to manually duplicate the interface of the `Timed` class in TimedInterface. The second is that we can't write `class Bar extends Timed(Foo) {}` because extending an expression isn't supported.
Contributor guide
Assessment
This issue has not been assessed yet.