Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide also raw interface definition instead of just class #9

Open
Granjow opened this issue Mar 19, 2022 · 0 comments
Open

Provide also raw interface definition instead of just class #9

Granjow opened this issue Mar 19, 2022 · 0 comments

Comments

@Granjow
Copy link

Granjow commented Mar 19, 2022

First, thanks for this helpful package @binier ! I used to manually declare onX(…) events to enforce typed events until I found it.

One thing I miss is a plain interface definition which I can inherit.

export interface ITypedEmitter<L extends ListenerSignature<L> = DefaultListener> {
    addListener<U extends keyof L>( event: U, listener: L[U] ): this;
    prependListener<U extends keyof L>( event: U, listener: L[U] ): this;
    // etc.
}

export interface MyInterfaceWithEvents extends ITypedEmitter<MyEvents> {
    // …
}

so users of the interface can also rely on typed events, not only users of the instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant