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

Type Error: Argument of type 'string | undefined' in shoutConnected #41

Open
heydarideveloper opened this issue Oct 15, 2024 · 1 comment

Comments

@heydarideveloper
Copy link
Contributor

Hi there,
I encountered a TypeScript error while using the shoutConnected(connection.id) function in the react-signalr package. The error message is as follows:

Argument of type 'string | undefined' is not assignable to parameter of type 'string | null'.
Type 'undefined' is not assignable to type 'string | null'.

Issue Description
The issue occurs because connection.id can potentially be undefined, but the shoutConnected function expects a parameter that is either a string or null.
Proposed Solution
To fix this issue, I modified the function call to ensure it only passes a valid string or null value. I implemented the following change:

shoutConnected(connection.id || null);

This adjustment ensures that if connection.id is undefined, it will pass null instead, which aligns with the expected parameter type.
Merge Request
I have created a merge request with this fix. You can find it here: #40 (comment)
Thank you for your attention to this matter! I hope this helps improve the package for everyone.
Best regards,
[heydarideveloper] Feel free to customize any part of the message before submitting it!

@hosseinmd
Copy link
Owner

There is a breaking change of socket.io in v4.8.0.
To workaround, please install v4.2.0 of socket.io

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

No branches or pull requests

2 participants