You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is a problem when using addEventListener since typescript is unable to infer the inner type of SignalType
ws.addEventListener("ice",(event)=>{//In this case typescript doesn't know that event is of type Event & { type: "ice", data: ICEEvent }//and so it amuses is Event & SignalType (which is not what we want since this is too generic)})
Solution
To fix this issue, the SignalType type definition can be redefined to be more specific by creating individual types for each event type instead of using a union type. The resulting SignalType type definition would look like the following:
Problem
When working with typescript something like the following
could cause some problems in some edge cases like when using the following class
in this case if I create a class that extend that class like the following
there is a problem when using addEventListener since typescript is unable to infer the inner type of SignalType
Solution
To fix this issue, the SignalType type definition can be redefined to be more specific by creating individual types for each event type instead of using a union type. The resulting SignalType type definition would look like the following:
The text was updated successfully, but these errors were encountered: