Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript type definitions incorrect for Command class #787

Closed
abedra opened this issue Apr 9, 2018 · 8 comments
Closed

Typescript type definitions incorrect for Command class #787

abedra opened this issue Apr 9, 2018 · 8 comments
Labels
docs README (or other docs) could be improved

Comments

@abedra
Copy link

abedra commented Apr 9, 2018

When compiling a typescript project the following error is produced

node_modules/commander/typings/index.d.ts(26,25): error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?
@ivankostov
Copy link

Same issue for me - commander - 2.15.1, typescript 2.8.1.
Workaround is to remove the extends statement
before:
class Command extends NodeJS.EventEmitter {
after:
class Command {
Command does not implement any of the EventEmmiter's functions.

@avendiart
Copy link

Adding @types/node to devDependencies has fixed the issue for us.

@kushwahashiv
Copy link

kushwahashiv commented Aug 16, 2018

I also get an error TypeError: cmd.command is not a function
using with TypeScript 2.9.1

@arzyu
Copy link

arzyu commented Dec 17, 2018

@types/node should be added as a dependency in commender.js. As a temporary solution, I add it to my own package before this done.

@shadowspawn
Copy link
Collaborator

We should document that intend end-user to install @types/node.

@shadowspawn shadowspawn added the docs README (or other docs) could be improved label Mar 18, 2019
@shadowspawn
Copy link
Collaborator

Added TypeScript tips in README. Hopefully that helps.
https://github.com/tj/commander.js#typescript

kazboo pushed a commit to kazboo/create-electron-app-ts that referenced this issue Apr 14, 2020
* tj/commander.js#787
* 最新(13)だと動かない
SmileyJames added a commit to SmileyJames/capacitor that referenced this issue Jun 2, 2020
Kept encountering this error when compiling:

node_modules/commander/typings/index.d.ts:26:25 - error TS2689: Cannot
extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'?

Had the add node/types specifically for version 12

tj/commander.js#787
DefinitelyTyped/DefinitelyTyped@c47a34e#r36559684
@8Observer8
Copy link

Same issue for me - commander - 2.15.1, typescript 2.8.1.
Workaround is to remove the extends statement
before:
class Command extends NodeJS.EventEmitter {
after:
class Command {
Command does not implement any of the EventEmmiter's functions.

Thank you! This solution works for Electron 9 and Node 12.

@shadowspawn
Copy link
Collaborator

For future readers still using older versions of Commander, I'll add a link to the older README instructions:
https://github.com/tj/commander.js/tree/v4.1.1#typescript

The TypeScript dependency on NodeJS.EventEmitter was removed in #1146 which shipped in Commander v5.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs README (or other docs) could be improved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants