mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-10 07:28:06 -05:00
fix(typings): accept string | undefined as init argument
Related: https://github.com/socketio/socket.io/issues/4873
This commit is contained in:
@@ -28,11 +28,7 @@ function lookup(
|
||||
opts?: Partial<ManagerOptions & SocketOptions>
|
||||
): Socket;
|
||||
function lookup(
|
||||
uri: string | Partial<ManagerOptions & SocketOptions>,
|
||||
opts?: Partial<ManagerOptions & SocketOptions>
|
||||
): Socket;
|
||||
function lookup(
|
||||
uri: string | Partial<ManagerOptions & SocketOptions>,
|
||||
uri?: string | Partial<ManagerOptions & SocketOptions>,
|
||||
opts?: Partial<ManagerOptions & SocketOptions>
|
||||
): Socket {
|
||||
if (typeof uri === "object") {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* @see https://webdriver.io/docs/frameworks/#using-mocha
|
||||
* @param fn
|
||||
*/
|
||||
export function wrap(fn) {
|
||||
return new Promise((resolve) => fn(resolve));
|
||||
export function wrap(fn: (done: (err?: Error) => void) => void) {
|
||||
return new Promise<Error>((resolve) => fn(resolve));
|
||||
}
|
||||
|
||||
export function success(done, socket) {
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
import { io, Socket } from "..";
|
||||
import type { DefaultEventsMap } from "@socket.io/component-emitter";
|
||||
import { expectError, expectType } from "tsd";
|
||||
import { createServer } from "http";
|
||||
|
||||
// This file is run by tsd, not mocha.
|
||||
|
||||
describe("init", () => {
|
||||
io();
|
||||
io("https://example.com");
|
||||
io({
|
||||
forceNew: true,
|
||||
});
|
||||
io("https://example.com", {
|
||||
forceNew: true,
|
||||
});
|
||||
io(process.env.NODE_ENV === "production" ? "https://example.com" : undefined);
|
||||
});
|
||||
|
||||
describe("typed events", () => {
|
||||
describe("no event map", () => {
|
||||
describe("on", () => {
|
||||
|
||||
Reference in New Issue
Block a user