From 99a3d8b3a016c89013ea27a862ffd554402379ac Mon Sep 17 00:00:00 2001 From: jeffmo Date: Mon, 24 Nov 2014 14:16:26 -0500 Subject: [PATCH] Add type signature for node `events` module --- lib/node.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/node.js b/lib/node.js index 2fb2c0de061..976403b4267 100644 --- a/lib/node.js +++ b/lib/node.js @@ -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; + on(event: string, listener: Function): events$EventEmitter; + once(event: string, listener: Function): events$EventEmitter; + removeAllListeners(events?: Array): 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" {