diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..0e00dd3 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,18 @@ +interface Emitter { + on(event: Event, listener: Function): Emitter; + once(event: Event, listener: Function): Emitter; + off(event?: Event, listener?: Function): Emitter; + emit(event: Event, ...args: any[]): Emitter; + listeners(event: Event): Function[]; + hasListeners(event: Event): boolean; + removeListener(event?: Event, listener?: Function): Emitter; + removeEventListener(event?: Event, listener?: Function): Emitter; + removeAllListeners(event?: Event): Emitter; +} + +declare const Emitter: { + (obj?: object): Emitter; + new (obj?: object): Emitter; +}; + +export = Emitter; diff --git a/package.json b/package.json index 403b8c0..7b8080d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ } }, "main": "index.js", + "types": "index.d.ts", "repository": { "type": "git", "url": "https://github.com/component/emitter.git" @@ -22,6 +23,7 @@ }, "files": [ "index.js", + "index.d.ts", "LICENSE" ] }