Skip to content

Commit

Permalink
Add type signature for node events module
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmo committed Nov 25, 2014
1 parent 498a4c6 commit 99a3d8b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,27 @@ declare module "domain" {
declare function create(): domain$Domain;
}

type events$EventEmitter = {

};
// TODO: This is copypast of the EventEmitter class signature exported from the
// `events` module. The only reason this exists is because other module
// interface definitions need to reference this type structure -- but
// referencing type structures defined in other modules isn't possible at
// the time of this writing.
declare class events$EventEmitter {
static listenerCount(emitter: events$EventEmitter, event: string): number;

addListener(event: string, listener: Function): events$EventEmitter;
emit(event: string, ...args:Array): boolean;
listeners(event: string): Array<Function>;
on(event: string, listener: Function): events$EventEmitter;
once(event: string, listener: Function): events$EventEmitter;
removeAllListeners(events?: Array<string>): events$EventEmitter;
removeListener(event: string, listener: Function): events$EventEmitter;
setMaxListeners(n: number): void;
}

declare module "events" {
// TODO
// TODO: See the comment above the events$EventEmitter declaration
declare class EventEmitter extends events$EventEmitter {}
}

declare module "fs" {
Expand Down

0 comments on commit 99a3d8b

Please sign in to comment.