-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change TS types to use type declarations from PN JS SDK #155
base: master
Are you sure you want to change the base?
Conversation
…mmunity driven @types/pubnub
src/jsMain/resources/index.d.ts
Outdated
userMetadata?: { | ||
[key: string]: any; | ||
}; | ||
}; | ||
type MessageDTOParams = PubNub.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent; | ||
type MessageDTOParams = History.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent; |
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.
type MessageDTOParams = History.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent; | |
type MessageDTOParams = History.FetchMessagesForChannelsResponse['channels'][string][number] | History.FetchMessagesWithActionsResponse['channels'][string][number] | EnhancedMessageEvent; |
I don't know where it used, just assuming what it expected to reflect.
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.
just checking that I should change [0] to [number] ? (I don't know TS types that well so wanted to make sure it's not a mistake)
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.
Because there is actually no array, we are speaking about type declaration. With this annotation, we are telling TS that we need the type of the single entry for the array of messages for channel name stored as a string.
Sadly, we have to use explicit types which have been unified under FetchMessagesResponse
because TS will end up with specifying any
because it can't figure out :/
(instead of community driven
@types/pubnub
)