electron/index.d.ts
file in this repo and had problems.It gave me following error after running tsc:
typings/globals/electron/index.d.ts(1860,8): error TS2420: Class 'Electron.EventEmitter'
incorrectly implements interface 'NodeJS.EventEmitter'.
Property 'prependListener' is missing in type 'EventEmitter'.
I guess it should be 'extends' rather than 'implements'.
please send a pull request. I'll review it.
Yes, EventEmitter
should be treated as a class, not just an interface, so extends
is called for.. See #10815. Root cause is the same: Node 6 adds three new methods to the class. In commit #10888 fixed this in one electron-related source file, github-electron/github-electron.d.ts
line 10.
I'm unclear where the definition being referenced as line 1860 actually lives in source control, but I've gotten a copy of the file using the command typings i -G env~electron
.
The installed file says:
// Generated by typings
// Source: https://raw.githubusercontent.com/types/env-electron/881826440171809e644a827fd3f85ba3c96a0422/lib/event-emitter.d.ts
declare namespace Electron {
class EventEmitter implements NodeJS.EventEmitter {
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
...
The source code causing this message is actually in a different repository. Types/env-electron a copy of the code still has the implements
rather than extends
.
@blakeembrey might be good to look at this? I submitted a PR in the other repository, reducing the amount of code duplication, but frankly I don't understand the "env~" stuff well enough to be confident it will meet with your approval.
@csudarshan07, in the meantime, might it make sense for you to use dt~github-electron rather than env~electron?
@BurtHarris I have this same issue with
"github-electron": "registry:dt/github-electron#1.4.1+20160928142324"
@BurtHarris Did you install recently? We merged that PR 22 days ago and it should be good to use. Anyone installing should get the version with your PR - see http://api.typings.org/entries/env/electron/versions/latest.
Edit: Sorry, the fix should be all good. I missed your post was from 22 days ago also 😄 Looks like DefinitelyTyped version has issues.
I installed it today. So is the recommendation the env not the dt version?
On Fri, Sep 30, 2016 at 12:07 PM Blake Embrey [email protected]
wrote:
@BurtHarris https://github.com/BurtHarris Did you install recently? We
merged that PR 22 days ago and it should be good to use. Anyone installing
should get the version with your PR - see
http://api.typings.org/entries/env/electron/versions/latest.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10977#issuecomment-250827397,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACFSMbBpQns-q7PaSuVVWkSCDPd3kELoks5qvV3YgaJpZM4JzcTC
.
Maximilian Alexander
[email protected]
www.maxofeden.com
@mbalex99 You could try it, but DefinitelyTyped looks to be maintaining it well lately. At least the error wouldn't exist in env~
, but there may be other differences. My guess is your error comes from the fact they've re-implements most of the EventEmitter
themselves and maybe there's some incompatibility with your version of node.d.ts
(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/github-electron/github-electron.d.ts#L10-L21). Can you post the error you get?
@blakeembrey I'm having the opposite of this error:
typings/globals/github-electron/index.d.ts(5,29): error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
It doesn't work with extends
. Changing the extends
to implements
fixes it.
I got the same error today with a fresh install of typings
.
The repro steps are the following:
typings install env~node --global --save
typings install env~electron --global --save
tsc
# error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
I'm not sure if this will help but here is the typings.json
file:
{
"globalDependencies": {
"electron": "registry:env/electron#0.37.6+20160909065630",
"node": "registry:env/node#6.0.0+20161019193037"
}
}
Thanks. It appears that env~node
is an interface, I would recommend the Electron definitions extend directly from the events
module instead of the implicit global though. I'll make a comment about it.
@blakeembrey I'm having the opposite of this error:
typings/globals/github-electron/index.d.ts(5,29): error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
It doesn't work with
extends
. Changing theextends
toimplements
fixes it.
I'm having this issue too on tsc:
```node_modules/electron/electron.d.ts:1655:31 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
1655 class BrowserWindow extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:3013:31 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
3013 class ClientRequest extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:3450:25 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
3450 class Cookies extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:3603:26 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
3603 class Debugger extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:4128:30 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
4128 class DownloadItem extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:4497:33 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
4497 class IncomingMessage extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:5341:30 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
5341 class Notification extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:6186:25 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
6186 class Session extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7111:37 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7111 class TouchBarColorPicker extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7123:31 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7123 class TouchBarGroup extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7133:31 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7133 class TouchBarLabel extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7145:33 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7145 class TouchBarPopover extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7157:34 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7157 class TouchBarScrubber extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7173:42 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7173 class TouchBarSegmentedControl extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7186:32 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7186 class TouchBarSlider extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7200:32 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7200 class TouchBarSpacer extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7321:22 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7321 class Tray extends NodeJS.EventEmitter {
~~
node_modules/electron/electron.d.ts:7756:29 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
7756 class WebContents extends NodeJS.EventEmitter {
~~
```
electron: 7.1.7
node: 13.5.0
typescript: 3.7.4
@types/node: 13.1.2
@Judahh It's solved?
Having the same problem, after upgrading Electron to v 7.x.
Just wonder if anyone made it working without manually updating node_modules\electron\electron.d.ts
- which sounds a bit odd to me.
Moreover, changing extends
to implements
is not enough:
This is an issue for users running Node v13+
. The issue is being tracked on the Electron repo: https://github.com/electron/electron/issues/21612
Use @types/node
for Node v12 for now. Actually Node version of Electron is still v12. So @types/node@12
would be better when you write a code which runs on Electron.
Aha, I see! Thank you.
Most helpful comment
Use
@types/node
for Node v12 for now. Actually Node version of Electron is still v12. So@types/node@12
would be better when you write a code which runs on Electron.