Skip to content

Type inconsistencies with query option #679

@kaangokdemir

Description

@kaangokdemir

Describe the bug
According to Socket IO's documentation, query option could be a number as well and with JavaScript, it works as it expected. However there are Type errors with Typescript

To Reproduce

Client

// my-file.ts (Example from docs)
import { io } from "socket.io-client";

const socket = io({
  query: {
    x: 42
  }
});

Expected behavior
No Type errors.

Received Errror

No overload matches this call.
  Overload 1 of 3, '(uri: string, opts?: Partial<ManagerOptions & SocketOptions>): Socket<DefaultEventsMap, DefaultEventsMap>', gave the following error.
    Type 'number' is not assignable to type 'string'.
  Overload 2 of 3, '(uri: string | Partial<ManagerOptions & SocketOptions>, opts?: Partial<ManagerOptions & SocketOptions>): Socket<...>', gave the following error.
    Type 'number' is not assignable to type 'string'.ts(2769)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions