diff --git a/test/types/dispatcher.test-d.ts b/test/types/dispatcher.test-d.ts index 00d9c7ded82..df9b32838c8 100644 --- a/test/types/dispatcher.test-d.ts +++ b/test/types/dispatcher.test-d.ts @@ -1,6 +1,6 @@ import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'node:http' import { Duplex, Readable, Writable } from 'node:stream' -import { expectAssignable, expectType } from 'tsd' +import { expectAssignable, expectNotAssignable, expectType } from 'tsd' import { Dispatcher, Headers } from '../..' import { URL } from 'node:url' import { Blob } from 'node:buffer' @@ -53,6 +53,11 @@ expectAssignable(new Dispatcher()) expectAssignable(dispatcher.dispatch({ origin: new URL('http://localhost'), path: '', method: 'GET' }, {})) expectAssignable(dispatcher.dispatch({ path: '', method: 'CUSTOM' }, {})) + // upgrade must be string or null, not boolean + expectNotAssignable({ path: '/', method: 'GET', upgrade: true }) + expectAssignable({ path: '/', method: 'GET', upgrade: 'websocket' }) + expectAssignable({ path: '/', method: 'GET', upgrade: null }) + // connect expectAssignable>(dispatcher.connect({ origin: '', path: '' })) expectAssignable>(dispatcher.connect({ origin: new URL('http://localhost'), path: '' })) diff --git a/types/dispatcher.d.ts b/types/dispatcher.d.ts index f732ec45cc9..a61f4d8dee6 100644 --- a/types/dispatcher.d.ts +++ b/types/dispatcher.d.ts @@ -114,7 +114,7 @@ declare namespace Dispatcher { /** The IP Type of Service (ToS) value for the request socket. Must be an integer between 0 and 255. Default: `0` */ typeOfService?: number | null; /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */ - upgrade?: boolean | string | null; + upgrade?: string | null; /** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */ headersTimeout?: number | null; /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */