Compiling some initial issues with the new Typescript (v4) chat client
First off great to see Sendbird moving to first class Typescript support!
We are running into some initial issues around creating a type safe client with the new module system.
let sendbirdChat: SendbirdChat;
const init = () => {
if (!sendbirdChat) {
sendbirdChat = SendbirdChat.init({
appId: 'APP_ID',
localCacheEnabled: true,
modules: [new GroupChannelModule()],
useAsyncStorageStore: AsyncStorage,
});
}
return sendbirdChat;
};
// @ts-expect-error Property 'groupChannel' does not exist on type 'SendbirdChat'
sendbirdChat.groupChannel
Any suggestions for how to create a type safe client that uses modules?
We could work around this if ModuleNamespaces
and Modules
types were exposed publicly
Less urgent but the type definition for AsyncStorageStatic
is incompatible with @react-native-async-storage/async-storage
Types of property 'getItem' are incompatible.
Type '(key: string, callback?: CallbackWithResult<string> | undefined) => Promise<string | null>' is not assignable to type '(key: string, callback?: ((error?: Error | undefined, result?: string | undefined) => void) | undefined) => Promise<string | null>'.
Types of parameters 'callback' and 'callback' are incompatible.
Types of parameters 'error' and 'error' are incompatible.
Type 'Error | null | undefined' is not assignable to type 'Error | undefined'.
Type 'null' is not assignable to type 'Error | undefined'.ts(2322)
__definition.d.ts(868, 3): The expected type comes from property 'useAsyncStorageStore' which is declared here on type 'SendbirdChatParams<GroupChannelModule[]>'