google / google/closure-compiler
No Interfaces can only extend interfaces without "= function () {}"
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I want an interface to extend a constructor. It's always been working fine like so
```js
/**
* The application interface.
* @extends {events.EventEmitter}
* @interface
*/
_goa.Application
```
This did behave indeed like an interface, I could annotate JS code like `@implements {_goa.Application}`.
I then added the assignment `= function() {}`
```js
/**
* The application interface.
* @extends {events.EventEmitter}
* @interface
*/
_goa.Application = function() {}
```
This started giving me the warning
```
types/externs/application.js:13: WARNING - [JSC_CONFLICTING_EXTENDED_TYPE]
_goa.Application cannot extend this type; interfaces can only extend interfaces
```
I think you should allow to extend constructors because the two are closely related, and tsicle will generate constructors and not interfaces. The difference is pretty subtle anyway, there's not interface concept in JS so I intuitively know what the difference is but it's hard to explain, it can be only explained in terms what you can and cannot do with both, like write `@implements` for interfaces.
https://github.com/google/closure-compiler/issues/937 this was closed
So this issue, is that there's no `interfaces can only extend interfaces` check on interfaces without `= function() {}` in externs, but please don't add it because say Node.JS API has EventEmitter, which is a constructor (maybe I should actually rename it to interface, like here I struggle to understand what the difference is, it's an implementation and and interface at the same time, so why should't I be able to create an interface which extends it... in any way, you get the idea.
Contributor guide
Assessment
This issue has not been assessed yet.