Returning unknown from events.subscribe, as the types do today, sucks if you're writing tests:
This PR attempts to address this by tweaking the return type of subscribe, which is conditional based on what kind of event handler function you pass into subscribe:
With these changes, now my tests are tidier with less IDE complaints. With an async handler the result looks like:
.. and using a callback interface, too:
No matter which style of handler you pass, at least in the context of my tests, now my IDE knows that I am dealing with functions - even the right kinds to boot!
Returning
unknown
fromevents.subscribe
, as the types do today, sucks if you're writing tests:This PR attempts to address this by tweaking the return type of
subscribe
, which is conditional based on what kind of event handler function you pass intosubscribe
:subscribe
returns an async function.With these changes, now my tests are tidier with less IDE complaints. With an async handler the result looks like:
.. and using a callback interface, too:
No matter which style of handler you pass, at least in the context of my tests, now my IDE knows that I am dealing with functions - even the right kinds to boot!