Open
Description
Description:
This could just be that I'm a novice with TypeScript, but I'm using this library in my project and I would like to reference the EventHandlersDataMap
type. I don't think I can currently do that as the file concerned isn't available in node_modules.
I've tried getting hold of the map with this, but it feels hacky/wrong and I'm still unsure how to type an event handler to a specific use-case:
import ObsWebSocket from 'obs-websocket-js';
const obs = new ObsWebSocket();
type OnParams = Parameters<typeof obs.on>;
export type EventHandlerKey = OnParams[0];
export type EventHandlerListener = OnParams[1];
export type ObsSocketListener = Partial<Record<EventHandlerKey, EventHandlerListener>>;
This is how I'm trying to get a specific data map for an event handler:
type ProfileChangedHandler = Extract<EventHandlerListener, { profile: string; }> // <- Always returns 'never'
// expecting `ProfileChangeHandler` to be `{ profile: string; }`
It looks like obsWebsocket.ts would be a lot easier to do this kind of thing, is that possible?
Versions Used (if applicable):
- obs-websocket-js version: 4.0.3
Metadata
Metadata
Assignees
Labels
No labels