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

Better socket.off events name type. #1501

Closed
AbdUlHamedMaree opened this issue Oct 9, 2021 · 2 comments
Closed

Better socket.off events name type. #1501

AbdUlHamedMaree opened this issue Oct 9, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@AbdUlHamedMaree
Copy link
Contributor

Describe the bug
when I start using socket.io-client with typescript, I initilized my socket with the following code:

const socket:Socket<ListenerEvents, EmitEvents> = io('URL');

so if I use socket.on it will help me with ListenersEvents types, but when using socket.off it will not.

To Reproduce
the above code.

Expected behavior
the function socket.off be better in types.

Platform:

  • Device: Lenovo
  • OS: Ubuntu

Additional context
I looked at the typed-events.d.ts file and it looks like StrictEventEmitter extends from the Emitter interface without passing the names of the events, but on the other hand, the StrictEventEmitter class has implements the same functions that exist in the Emitter interface (why?!) so implement the off function and that's it!.

I think this is enough to explain the bug and the solution.

@AbdUlHamedMaree AbdUlHamedMaree added the bug Something isn't working label Oct 9, 2021
@darrachequesne
Copy link
Member

Hi! The StrictEventEmitter class indeed does not cover the whole API of the Emitter.

Would you have time to open a pull request for this? Thanks!

@darrachequesne darrachequesne added enhancement New feature or request and removed bug Something isn't working labels Oct 12, 2021
@darrachequesne
Copy link
Member

darrachequesne commented Oct 14, 2021

Fixed by #1502

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

No branches or pull requests

2 participants