In the current version, we have to define the type of callback function manually:
// ❌ no type
OpenIM.on(CbEvents.OnUserStatusChanged, (event) => {
// The type of event is WSEvent<any>
event.data // any
})
// 🤔 manually typed
OpenIM.on(CbEvents.OnUserStatusChanged, (event: WSEvent<UserOnlineState>) => {
// The type of event is WSEvent<UserOnlineState>
event.data // UserOnlineState
})
In order to improve developer experience, I suggest adding type inference so that developer can just:
Why this feature?
In the current version, we have to define the type of callback function manually:
In order to improve developer experience, I suggest adding type inference so that developer can just:
Suggested Solution
CbEvents
and the corresponding data.emit()
,on()
andoff()
inEmitter
classAdditional Information
See pull request #87
No response