Skip to content

Commit 245fda2

Browse files
authored
fix: Add types of GroupChat and OpenChat for SendbirdChat (#518)
### Description Of Changes Issue * Customer had to use the type assertion for removing type error ```javascript const globalState = useSendbirdStateContext() const getSdk = sendbirdSelectors.getSdk(globalState) as SendbirdGroupChat; getSdk.groupChannel.getTotalUnreadMessageCount(); ``` Fix * Specify the `getSdk` returns SendbirdGroupChat or SendbirdOpenChat
1 parent ce69ebc commit 245fda2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

scripts/index_d_ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
declare module "SendbirdUIKitGlobal" {
77
import type React from 'react';
8-
import type Locale from 'date-fns';
98
import type SendbirdChat from '@sendbird/chat';
109
import type {
1110
SendbirdError,
@@ -148,7 +147,7 @@ declare module "SendbirdUIKitGlobal" {
148147
export type EveryMessage = ClientUserMessage | ClientFileMessage | ClientAdminMessage;
149148
export type ClientSentMessages = ClientUserMessage | ClientFileMessage;
150149

151-
export type GetSdk = SendbirdChat | undefined;
150+
export type GetSdk = SendbirdChat | SendbirdGroupChat | SendbirdOpenChat | undefined;
152151
export type GetConnect = (
153152
userId: string,
154153
accessToken?: string
@@ -229,7 +228,7 @@ declare module "SendbirdUIKitGlobal" {
229228
userId: string;
230229
appId: string;
231230
accessToken?: string;
232-
configureSession?: (sdk: SendbirdChat) => SessionHandler;
231+
configureSession?: (sdk: SendbirdChat | SendbirdGroupChat | SendbirdOpenChat) => SessionHandler;
233232
customApiHost?: string,
234233
customWebSocketHost?: string,
235234
children?: React.ReactElement;

src/lib/hooks/useConnect/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import SendbirdChat, { SessionHandler } from '@sendbird/chat';
2+
import { SendbirdGroupChat } from '@sendbird/chat/groupChannel';
3+
import { SendbirdOpenChat } from '@sendbird/chat/openChannel';
24

35
import { SdkActionTypes } from '../../dux/sdk/actionTypes';
46
import { UserActionTypes } from '../../dux/user/actionTypes';
@@ -14,7 +16,7 @@ export type TriggerTypes = {
1416
accessToken?: string;
1517
}
1618

17-
export type ConfigureSessionTypes = (sdk: SendbirdChat) => SessionHandler;
19+
export type ConfigureSessionTypes = (sdk: SendbirdChat | SendbirdGroupChat | SendbirdOpenChat) => SessionHandler;
1820

1921
export type StaticTypes = {
2022
nickname: string;

0 commit comments

Comments
 (0)