-
Notifications
You must be signed in to change notification settings - Fork 17
Follow Up to addressing #1258 comments #1260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Check this comment as well: https://github.com/signalwire/signalwire-js/pull/1258/files#r2216451899 I am not sure if you understood the comment. Since you have defined two different params, it means the Let me know if you have any questions. |
Yes, but a Developer are not required to use the convenience chat methods the receive chat events since a But we they use the chat methods they only get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Just highlighting this:
export interface ConversationMessageEvent extends SwEvent {
event_type: ConversationMessageEventName
params: ConversationMessageEventParams | ConversationChatMessageEventParams
}
export type ConversationEventParams = ConversationMessageEventParams | ConversationChatMessageEventParams
If you tell the TS that the conversation event can have params with two types, you would be able to avoid using unknown
in the type guard:
const isConversationChatEventParams = (
event: unknown // this can be replaced with ConversationEventParams
): event is ConversationChatEventParams => {
return (
typeof event === 'object' &&
event !== null &&
'subtype' in event &&
event.subtype === 'chat' &&
'user_name' in event &&
'text' in event
)
}
Description
Follow Up to addressing #1258 comments
Type of change
Code snippets
In case of new feature or breaking changes, please include code snippets.