Skip to content

Commit d08d782

Browse files
zbuttramdevelopit
authored andcommitted
Fix Typescript wildcard handler (#76)
* attempt to fix handler typedef for wildcard events * also fix wildcard handler typedef for .off
1 parent 0f4e8f0 commit d08d782

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mitt.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ declare module "mitt" {
66

77
declare namespace mitt {
88
type Handler = (event?: any) => void;
9+
type WildcardHandler = (type?: string, event?: any) => void;
910

1011
interface MittStatic {
1112
(all?: {[key: string]: Handler}): Emitter;
@@ -21,6 +22,7 @@ declare namespace mitt {
2122
* @memberOf Mitt
2223
*/
2324
on(type: string, handler: Handler): void;
25+
on(type: "*", handler: WildcardHandler): void;
2426

2527
/**
2628
* Function to call in response to the given event
@@ -31,6 +33,7 @@ declare namespace mitt {
3133
* @memberOf Mitt
3234
*/
3335
off(type: string, handler: Handler): void;
36+
off(type: "*", handler: WildcardHandler): void;
3437

3538
/**
3639
* Invoke all handlers for the given type.

0 commit comments

Comments
 (0)