Skip to content

Commit

Permalink
Remove EventEmitter from TypeScript definition file (#1146)
Browse files Browse the repository at this point in the history
* Remove NodeJS.EventEmitter from TypeScript definition

* Add symbol

It is JavaScript not node and ok to include to match EventEmitter defintition
  • Loading branch information
shadowspawn committed Jan 11, 2020
1 parent 68e584f commit c448afb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 1 addition & 6 deletions Readme.md
Expand Up @@ -605,12 +605,7 @@ console.log(programOptions.name);
### TypeScript
The Commander package includes its TypeScript Definition file, but also requires the node types which you need to install yourself. e.g.
```bash
npm install commander
npm install --save-dev @types/node
```
The Commander package includes its TypeScript Definition file.
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.
Expand Down
15 changes: 12 additions & 3 deletions typings/index.d.ts
@@ -1,8 +1,6 @@
// Type definitions for commander
// 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>

///<reference types="node" />

declare namespace commander {

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

interface Command extends NodeJS.EventEmitter {
interface Command {
[key: string]: any; // options as properties

args: string[];
Expand Down Expand Up @@ -286,6 +284,17 @@ declare namespace commander {
* Output help information and exit.
*/
help(cb?: (str: string) => string): never;

/**
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
*
* @example
* program
* .on('--help', () -> {
* console.log('See web site for more information.');
* });
*/
on(event: string | symbol, listener: (...args: any[]) => void): Command;
}
type CommandConstructor = { new (name?: string): Command };

Expand Down

0 comments on commit c448afb

Please sign in to comment.