Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/types/dispatcher.test-d.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -53,6 +53,11 @@ expectAssignable<Dispatcher>(new Dispatcher())
expectAssignable<boolean>(dispatcher.dispatch({ origin: new URL('http://localhost'), path: '', method: 'GET' }, {}))
expectAssignable<boolean>(dispatcher.dispatch({ path: '', method: 'CUSTOM' }, {}))

// upgrade must be string or null, not boolean
expectNotAssignable<Dispatcher.DispatchOptions>({ path: '/', method: 'GET', upgrade: true })
expectAssignable<Dispatcher.DispatchOptions>({ path: '/', method: 'GET', upgrade: 'websocket' })
expectAssignable<Dispatcher.DispatchOptions>({ path: '/', method: 'GET', upgrade: null })

// connect
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: '', path: '' }))
expectAssignable<Promise<Dispatcher.ConnectData>>(dispatcher.connect({ origin: new URL('http://localhost'), path: '' }))
Expand Down
2 changes: 1 addition & 1 deletion types/dispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading