Skip to content

Commit c2ee043

Browse files
committed
reorder type declarations to produce a smaller diff
1 parent d67e4ef commit c2ee043

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/types.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ export type InferEvent<TTarget, TType extends string> =
2020
? Parameters<Extract<TTarget[`on${TType}`], AnyFunction>>[0]
2121
: Event;
2222

23-
export type Listener<TTarget extends EventTarget, TEvent extends Event> =
24-
| { (this: TTarget, ev: TEvent): void }
25-
| ListenerObject<TEvent>;
26-
27-
interface ListenerObject<TEvent extends Event> {
28-
// For listener objects, the handleEvent function has the object as the `this` binding
23+
// For listener objects, the handleEvent function has the object as the `this` binding
24+
type ListenerObject<TEvent extends Event> = {
2925
handleEvent(this: ListenerObject<TEvent>, event: TEvent): void;
30-
}
26+
};
27+
28+
// event listeners can be an object or a function
29+
export type Listener<TTarget extends EventTarget, TEvent extends Event> =
30+
| ListenerObject<TEvent>
31+
| { (this: TTarget, ev: TEvent): void };
3132

3233
export type Binding<TTarget extends EventTarget = EventTarget, TType extends string = string> = {
3334
type: TType;

0 commit comments

Comments
 (0)