stream-chat-react-native icon indicating copy to clipboard operation
stream-chat-react-native copied to clipboard

While passing the stream client to the Chat component of stream-chat-react-native getting the error: Type 'StreamChat<DefaultGenerics>' is not assignable to type 'StreamChat<DefaultStreamChatGenerics>'.

Open vinaygregoryjohn183 opened this issue 2 years ago • 6 comments

BUG: Implementing 'Multiple conversations' referring the doc: https://getstream.io/chat/react-native-chat/tutorial/#:~:text=your%20Camera%20Roll.-,Multiple%20conversations,-Most%20chat%20applications getting the following error when passing client to <Chat> component: Error at line, while passing client prop: <Chat client={streamClient}> 'Type 'StreamChat<DefaultGenerics>' is not assignable to type 'StreamChat<DefaultStreamChatGenerics>'. Types of property 'activeChannels' are incompatible. Type '{ [key: string]: Channel<DefaultGenerics>; }' is not assignable to type '{ [key: string]: Channel<DefaultStreamChatGenerics>; }'. 'string' index signatures are incompatible. Type 'Channel<DefaultGenerics>' is not assignable to type 'Channel<DefaultStreamChatGenerics>'. Types of property 'listeners' are incompatible. Type '{ [key: string]: (string | EventHandler<DefaultGenerics>)[]; }' is not assignable to type '{ [key: string]: (string | EventHandler<DefaultStreamChatGenerics>)[]; }'. 'string' index signatures are incompatible. Type '(string | EventHandler<DefaultGenerics>)[]' is not assignable to type '(string | EventHandler<DefaultStreamChatGenerics>)[]'. Type 'string | EventHandler<DefaultGenerics>' is not assignable to type 'string | EventHandler<DefaultStreamChatGenerics>'. Type 'EventHandler<DefaultGenerics>' is not assignable to type 'string | EventHandler<DefaultStreamChatGenerics>'. Type 'EventHandler<DefaultGenerics>' is not assignable to type 'EventHandler<DefaultStreamChatGenerics>'. Types of parameters 'event' and 'event' are incompatible. Type 'Event<DefaultStreamChatGenerics>' is not assignable to type 'Event<DefaultGenerics>'. Type 'Event<DefaultStreamChatGenerics>' is not assignable to type '{ type: EventTypes; channel?: ChannelResponse<DefaultGenerics> | undefined; channel_id?: string | undefined; channel_type?: string | undefined; ... 19 more ...; watcher_count?: number | undefined; }'. Types of property 'channel' are incompatible.

Screenshot 2022-05-11 at 12 34 43 PM Type 'ChannelResponse | undefined' is not assignable to type 'ChannelResponse | undefined'. Type 'ChannelResponse' is not assignable to type 'ChannelResponse | undefined'.ts(2322) ChatContext.d.ts(21, 5): The expected type comes from property 'client' which is declared here on type 'IntrinsicAttributes & Pick, "client"> & { closeConnectionOnBackground?: boolean | undefined; i18nInstance?: Streami18n | undefined; style?: DeepPartial<...> | undefined; } & { ...; }'

ENVIRONMENT: Im using the stream-chat-react-native version 4.4.0 stream-chat version 6.5.1 react-native version 0.63.4

vinaygregoryjohn183 avatar May 11 '22 06:05 vinaygregoryjohn183

Duplicate of 1038 right @vinaygregoryjohn183 ?

vanGalilea avatar May 11 '22 06:05 vanGalilea

@vanGalileaIn the 1038 issue, the error is occurring at the same point in code as my code. But i'm getting a different type error message. Is the error caused by the same reason? If so this is a duplicate issue.

vinaygregoryjohn183 avatar May 11 '22 07:05 vinaygregoryjohn183

@vinaygregoryjohn183 they're similar and contain each other partially, leaving both open, and we're going to handle them together. Thank you!

vanGalilea avatar May 23 '22 06:05 vanGalilea

@vinaygregoryjohn183 I was facing the same problem. This issue is occurring due to import of StreamChat from stream-chat library and DefaultGenerics from stream-chat-react-native.

kcaaashir avatar Jun 02 '22 09:06 kcaaashir

Hey team! Please add your planning poker estimate with ZenHub @Enigma-I-am @khushal87 @madsroskar @santhoshvai @vishalnarkhede

vanGalilea avatar Jun 07 '22 08:06 vanGalilea

Can someone walk us thru the proper example?

billnbell avatar Sep 06 '22 16:09 billnbell

any updates or workarounds for this?

MaxAst avatar Mar 02 '23 09:03 MaxAst

@vanGalilea As a developer at a startup, I was looking into Stream Chat as a possible alternative to rolling our own chat system. While doing the spike card to look into this, I created a trial account and was following your own quickstart guide line for line when I ran into this issue very early on. I can't even use the starting, base <Chat> component without immediately hitting this TypeScript error. Starting off with a new library and having to use // @ts-expect-error right off the bat is not a great look.

I hope you understand, from this point of view, it doesn't make Stream Chat look like a great option, especially when I saw this has been an issue since December 2021.

This isn't meant to be a mean-spirited complaint by any means and I hope it doesn't come off that way, I just hoped this "user story" would maybe bring light to this from the customer side. Hope this gets fixed soon, as this otherwise seems like a fantastic product.

JosefBud avatar Mar 27 '23 02:03 JosefBud

I used to suffer from this, but don't seem to anymore. Not sure if this was how I fixed it, but it might be a workaround that helps others:

Use the same version of stream-chat that is used by stream-chat-react-native (or stream-chat-expo). e.g. when I look in my yarn.lock file I see that stream-chat-react-native-core 4.15.0 (the version I am using) depends on stream-chat ~6.7.3. Therefore if I need to directly use stream-chat, this is the version that I install, rather than the latest and greatest.

GregAtFramework avatar Mar 27 '23 07:03 GregAtFramework

@vanGalilea As a developer at a startup, I was looking into Stream Chat as a possible alternative to rolling our own chat system. While doing the spike card to look into this, I created a trial account and was following your own quickstart guide line for line when I ran into this issue very early on. I can't even use the starting, base <Chat> component without immediately hitting this TypeScript error. Starting off with a new library and having to use // @ts-expect-error right off the bat is not a great look.

I hope you understand, from this point of view, it doesn't make Stream Chat look like a great option, especially when I saw this has been an issue since December 2021.

This isn't meant to be a mean-spirited complaint by any means and I hope it doesn't come off that way, I just hoped this "user story" would maybe bring light to this from the customer side. Hope this gets fixed soon, as this otherwise seems like a fantastic product.

Thanks for sharing your experience. It's super essential for us to deliver a top-notch experience with our UI components. Yet the mentioned tutorial is a JS tutorial and not a TS one.

Please see our typescript messaging example to see a TS working solution.

I used to suffer from this, but don't seem to anymore. Not sure if this was how I fixed it, but it might be a workaround that helps others:

Use the same version of stream-chat that is used by stream-chat-react-native (or stream-chat-expo). e.g. when I look in my yarn.lock file I see that stream-chat-react-native-core 4.15.0 (the version I am using) depends on stream-chat ~6.7.3. Therefore if I need to directly use stream-chat, this is the version that I install, rather than the latest and greatest.

Also, make sure never to install stream-chat as its already a dependency of stream-chat-react-native!

vanGalilea avatar May 10 '23 15:05 vanGalilea