Skip to content

Incorrect Types for Client Initialisation #4873

Closed

Description

@piet-maier

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.

Activity

  1. added
    to triage
    on Nov 18, 2023
  2. darrachequesne commented on Nov 23, 2023

    @darrachequesne
    Member

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

  3. added
    bug
    and removed
    to triage
    on Nov 23, 2023
  4. darrachequesne commented on Oct 22, 2024

    @darrachequesne
    Member

    For future readers:

    This should be fixed in latest version ([email protected]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions