From 908fbc4f4c40e4aabb31212f9325e26ed25785ef Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne <damien.arrachequesne@gmail.com> Date: Mon, 4 Oct 2021 08:01:23 +0200 Subject: [PATCH] chore: add removeListener typings Related: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55968 --- index.d.ts | 18 ++++++++++++++++++ package.json | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 index.d.ts 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<Event = string> { + 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" ] }