问题描述
waitMessage<T extends IIPcmessagesConstructors>(wantedMessageType: T): Promise<// ?? //>
通过以下方式定义IIPcmessagesConstructurs的地方。
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;
我的函数waitMessage返回提供的构造函数的实例。那么如何将T的typeof转换为T?
解决方法
InstanceType<IIPCMessagesConstructors>
成功了