Skip to content

Commit 4f2e9a7

Browse files
fix(typings): update the types of "query", "auth" and "headers"
Related: #3770
1 parent 9e8f288 commit 4f2e9a7

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const dotMapRegex = /\.map/;
2525
type Transport = "polling" | "websocket";
2626
type ParentNspNameMatchFn = (
2727
name: string,
28-
query: object,
28+
auth: { [key: string]: any },
2929
fn: (err: Error | null, success: boolean) => void
3030
) => void;
3131

@@ -246,7 +246,7 @@ export class Server extends EventEmitter {
246246
*/
247247
_checkNamespace(
248248
name: string,
249-
auth: object,
249+
auth: { [key: string]: any },
250250
fn: (nsp: Namespace | false) => void
251251
): void {
252252
if (this.parentNsps.size === 0) return fn(false);

lib/socket.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import debugModule from "debug";
55
import type { Server } from "./index";
66
import type { Client } from "./client";
77
import type { Namespace } from "./namespace";
8-
import type { IncomingMessage } from "http";
8+
import type { IncomingMessage, IncomingHttpHeaders } from "http";
99
import type {
1010
Adapter,
1111
BroadcastFlags,
1212
Room,
1313
SocketId,
1414
} from "socket.io-adapter";
1515
import base64id from "base64id";
16+
import type { ParsedUrlQuery } from "querystring";
1617

1718
const debug = debugModule("socket.io:socket");
1819

@@ -33,7 +34,7 @@ export interface Handshake {
3334
/**
3435
* The headers sent as part of the handshake
3536
*/
36-
headers: object;
37+
headers: IncomingHttpHeaders;
3738

3839
/**
3940
* The date of creation (as string)
@@ -68,12 +69,12 @@ export interface Handshake {
6869
/**
6970
* The query object
7071
*/
71-
query: object;
72+
query: ParsedUrlQuery;
7273

7374
/**
7475
* The auth object
7576
*/
76-
auth: object;
77+
auth: { [key: string]: any };
7778
}
7879

7980
export class Socket extends EventEmitter {

0 commit comments

Comments
 (0)