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'?
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.
Adding @types/node to devDependencies has fixed the issue for us.
I also get an error TypeError: cmd.command is not a function
using with TypeScript 2.9.1
@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.
We should document that intend end-user to install @types/node.
Added TypeScript tips in README. Hopefully that helps.
https://github.com/tj/commander.js#typescript
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.
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.
Most helpful comment
Adding
@types/nodetodevDependencieshas fixed the issue for us.