stream-chat-react-native
stream-chat-react-native copied to clipboard
UserResponse<LocalUserType> is not assignable to type 'UserResponse<LocalUserType & OwnUserBase<LocalChannelType, string, LocalUserType>>'
Describe the bug Typescript 4.4.4 error with v3.10.2:
Type 'UserResponse<LocalUserType>' is missing the following properties from type 'OwnUserBase<LocalChannelType, string, LocalUserType>': channel_mutes, devices, mutes, total_unread_count, and 2 more.
Dev environment info (please complete/provide the following information):
- Package version stream-chat-react-native 3.10.2
- react-native
- Device/Emulator (iOS & simulator) and OS version 15.0
To Reproduce Steps to reproduce the behavior:
export type LocalAttachmentType = Record<string, unknown>;
export type LocalChannelType = Record<string, unknown>;
export type LocalCommandType = string;
export type LocalEventType = Record<string, unknown>;
export type LocalMessageType = Record<string, unknown>;
export type LocalReactionType = Record<string, unknown>;
export type LocalUserType = Record<string, unknown>;
const chatClient = StreamChat.getInstance<
LocalAttachmentType,
LocalChannelType,
LocalCommandType,
LocalEventType,
LocalMessageType,
LocalReactionType,
LocalUserType
>(API_KEY);
const ChatScreen = (): JSX.Element => {
return (
<SafeAreaView>
<Chat client={chatClient}>
...
</Chat>
</SafeAreaView>
);
};
- See error types of _user are incompatible
Expected behavior
expected to compile without typescript errors.
*Screenshots
*
gz#17229
Hey @skam22 could you please fork the repository and try to reproduce this issue in one of the example apps? https://github.com/GetStream/stream-chat-react-native/tree/develop/examples
I am also experiencing this exact problem in my own application. @skam22 did you find a work around?
I've just setup the stream-chat-react-native TypeScriptMessaging
example and see the same problem there too:
I can reproduce this in our sample apps. It looks like we have a couple of types that need updating, I'm looking into it. We're working on simplifying the types for the SDK at the moment, but I'll make a PR to resolve this in the sample apps in the meantime.
#This is a bit trickier to work around than I thought, so I don't have a solution just yet. For the time being, you could tell typescript to expect there to be an error reported there with @ts-expect-error
in a comment on the line above the line it's reporting the error to suppress the error message until we have a proper solution in place.
This seems to be an issue with our js client checking the wrong type for the User when it's being updated from an Event, so it looks like we'll have to fix the type definition there.
I'm creating an issue in our internal issue tracker, thanks for reporting it!
@delantai sorry for the late reply, I actually had implemented what @madsroskar suggested, basically commenting out the typescript error since it wasn’t preventing a successful build.
and for what it’s worth - it’s not just User that has this problem, it’s present in a number of other types as well.
Thanks for the replies, very helpful!
Side note, I'm seeing a similar thing for the channel
typing which is being passed via context in the example app.
In the onSelect
of ChannelListScreen
in the example app I'm seeing this:
In my app I'm also trying to access a channel in state via hook, and having the same difficulties as above.
Hey team! Please add your planning poker estimate with ZenHub @Enigma-I-am @khushal87 @madsroskar @santhoshvai @vishalnarkhede
Relates to 1357
This issue has become stale due to the old SDK version. Please see our typescript messaging example to see a working solution.