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

Incorrect Types for Client Initialisation #4873

Open
piet-maier opened this issue Nov 18, 2023 · 1 comment
Open

Incorrect Types for Client Initialisation #4873

piet-maier opened this issue Nov 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@piet-maier
Copy link

piet-maier commented Nov 18, 2023

Description

Initialising the socket.io client with an URL string or undefined depending on the environment (as in the Vue Example in the documentation) produces the following type error: "No overload matches this call."

It is possible to either pass a string or undefined in separate calls, but not a value that has the type string | undefined in one call.

Reproduction

Client Version: 4.7.2

import { io } from "socket.io-client";

const socket = io(import.meta.env.PROD ? undefined : "ws://localhost:3000/");

Expected Behaviour

There should not be a type error since the argument can be of either type, and the code works as expected.

@piet-maier piet-maier added the to triage Waiting to be triaged by a member of the team label Nov 18, 2023
@darrachequesne
Copy link
Member

I could indeed reproduce the issue, I'm digging into this.

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Nov 23, 2023
darrachequesne added a commit to socketio/socket.io-client that referenced this issue Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants