Skip to content
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

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

wkal-pubnub
Copy link
Contributor

@wkal-pubnub wkal-pubnub commented Jan 7, 2025

refactor: The JS Chat SDK now uses TS types from recent versions of PubNub JS SDK instead of the ones in the @types/pubnub community resource. Changes to customer code might be required to accommodate this change.

@wkal-pubnub wkal-pubnub requested a review from parfeon January 9, 2025 11:11
@wkal-pubnub wkal-pubnub marked this pull request as ready for review January 9, 2025 11:11
src/jsMain/resources/index.d.ts Outdated Show resolved Hide resolved
src/jsMain/resources/index.d.ts Outdated Show resolved Hide resolved
src/jsMain/resources/index.d.ts Outdated Show resolved Hide resolved
userMetadata?: {
[key: string]: any;
};
};
type MessageDTOParams = PubNub.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent;
type MessageDTOParams = History.FetchMessagesResponse["channels"]["channel"][0] | EnhancedMessageEvent;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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)

Copy link

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 :/

src/jsMain/resources/index.d.ts Outdated Show resolved Hide resolved
src/jsMain/resources/index.d.ts Outdated Show resolved Hide resolved
@wkal-pubnub wkal-pubnub force-pushed the wkal/js_sdk_new_types branch from ff8159e to 8f0aed8 Compare January 16, 2025 12:37
@wkal-pubnub wkal-pubnub requested a review from parfeon January 16, 2025 13:26
pin(): Promise<void>;
/** @deprecated */
DEPRECATED_report(reason: string): Promise<PubNub.SignalResponse>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that we are changing type in Deprecated method? If so it means that client should modify the code after upgrade? If so wouldn't be better to just remove this deprecated code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only the type name changes, the content is the same

we could remove this method in the future I guess, we can do a sweep before 1.0.0 and remove any deprecated patterns

@wkal-pubnub
Copy link
Contributor Author

@pubnub-release-bot release js as 0.11.0

@wkal-pubnub wkal-pubnub dismissed parfeon’s stale review January 16, 2025 15:00

as discussed, releasing this

@wkal-pubnub wkal-pubnub merged commit e55b101 into master Jan 16, 2025
2 checks passed
@wkal-pubnub wkal-pubnub deleted the wkal/js_sdk_new_types branch January 16, 2025 15:23
@pubnub-release-bot
Copy link
Contributor

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants