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

Remove EventEmitter from TypeScript definition file #1146

Merged
merged 2 commits into from Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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