One important aspect of my function is its signature, which looks like the following.
waitMessage<T extends IIPCMessagesConstructors>(wantedMessageType: T): Promise<// ?? //>
The definition of IIPCMessagesConstructors is crucial and consists of the following types.
export type IIPCMessagesConstructors = typeof OSUserRegistrationMessage |
typeof AppLaunchRequestMessage |
typeof OSUserRegistrationResponseMessage |
typeof UserApplicationRegistrationMessage |
typeof UserApplicationRegistrationResponseMessage |
typeof AppLaunchResponseMessage |
typeof InstallationCompleteMessage |
typeof InstallationInitCompleteMessage |
typeof InstallationProgressMessage |
typeof InstallationStartMessage |
typeof InstallationStopMessage;
Within my function waitMessage, the goal is to return an instance of the provided constructor. The challenge lies in converting typeof T to T. Any suggestions on how to achieve this?