Closed
Description
Describe the bug
The documentation indicates the following code for server initialisation with http2:
import { createSecureServer } from "http2";
import { Server } from "socket.io";
const httpServer = createSecureServer({...});
const io = new Server(httpServer, { /* options */ });
httpServer
is http2.Http2SecureServer
when calling new Server(httpServer, {})
, TS2769: No overload matches this call.
None of the signatures accepts Http2SecureServer.
The full error is:
TS2769: No overload matches this call.
Overload 1 of 3, '(srv?: number | import("http").Server<...> | import("https").Server<...> | undefined, opts?: Partial<...> | undefined): Server<...>', gave the following error.
Argument of type 'Http2SecureServer' is not assignable to parameter of type 'number | Server<...> | Server<...> | undefined'.
Type 'Http2SecureServer' is missing the following properties from type 'Server<typeof IncomingMessage, typeof ServerResponse>': closeAllConnections, closeIdleConnections, maxHeadersCount, maxRequestsPerSocket, and 4 more.
Overload 2 of 3, '(srv: number | import("http").Server<...> | import("https").Server<...> | Partial<...> | undefined, opts?: Partial<...> | undefined): Server<...>', gave the following error. Argument of type 'Http2SecureServer' is not assignable to parameter of type 'number | Server<...> | Server<...> | Partial<...> | undefined'.
Type 'Http2SecureServer' is not assignable to type 'Server<typeof IncomingMessage, typeof ServerResponse>'.
To Reproduce
Please fill the following code example:
Socket.IO server version: 4.5.2
Server
(copy-pasted 1:1 from https://socket.io/docs/v4/server-initialization/#with-an-http2-server for TypeScript)
import { readFileSync } from "fs";
import { createSecureServer } from "http2";
import { Server } from "socket.io";
const httpServer = createSecureServer({
allowHTTP1: true,
key: readFileSync("/path/to/my/key.pem"),
cert: readFileSync("/path/to/my/cert.pem")
});
const io = new Server(httpServer, { /* options */ });
Platform:
- Device: Razer Book 13
- OS: Ubuntu 22.04 LTS
- Node.js: v16.17.1
- npm: 8.15.0