Skip to content

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

@heydarideveloper

Description

@heydarideveloper

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions