Skip to content

How can I provide an intersected type to Socket's generic event type parameters? #4932

Answered by ZachHaber
westhom asked this question in Q&A
Discussion options

You must be logged in to vote

The issue that you are running into is that at the time typescript is trying to resolve the type of this.socket.on, the generics for the socket could be anything. Then due to the unresolved generic, the type parsing that's done in the library won't work correctly as those rely on the type being definable by typescript. It would be nice if typescript knew to resolve the bits it can resolve until the generic is specified and then resolves the whole thing with that generic. But given that the generic could be literally anything, even a type that is a union or an event map with conflicting values to the built-ins, it doesn't know how to fully resolve the types, so it doesn't. This leads to it…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@westhom
Comment options

@ZachHaber
Comment options

Answer selected by westhom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants