Skip to content

Commit c448afb

Browse files
authored
Remove EventEmitter from TypeScript definition file (#1146)
* Remove NodeJS.EventEmitter from TypeScript definition * Add symbol It is JavaScript not node and ok to include to match EventEmitter defintition
1 parent 68e584f commit c448afb

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Readme.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,7 @@ console.log(programOptions.name);
605605
606606
### TypeScript
607607
608-
The Commander package includes its TypeScript Definition file, but also requires the node types which you need to install yourself. e.g.
609-
610-
```bash
611-
npm install commander
612-
npm install --save-dev @types/node
613-
```
608+
The Commander package includes its TypeScript Definition file.
614609
615610
If you use `ts-node` and git-style sub-commands written as `.ts` files, you need to call your program through node to get the sub-commands called correctly. e.g.
616611

typings/index.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Type definitions for commander
22
// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
33

4-
///<reference types="node" />
5-
64
declare namespace commander {
75

86
interface CommanderError extends Error {
@@ -25,7 +23,7 @@ declare namespace commander {
2523
}
2624
type OptionConstructor = { new (flags: string, description?: string): Option };
2725

28-
interface Command extends NodeJS.EventEmitter {
26+
interface Command {
2927
[key: string]: any; // options as properties
3028

3129
args: string[];
@@ -286,6 +284,17 @@ declare namespace commander {
286284
* Output help information and exit.
287285
*/
288286
help(cb?: (str: string) => string): never;
287+
288+
/**
289+
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
290+
*
291+
* @example
292+
* program
293+
* .on('--help', () -> {
294+
* console.log('See web site for more information.');
295+
* });
296+
*/
297+
on(event: string | symbol, listener: (...args: any[]) => void): Command;
289298
}
290299
type CommandConstructor = { new (name?: string): Command };
291300

0 commit comments

Comments
 (0)