Skip to content

Commit 08bf6ec

Browse files
committed
fix(proxy): type errors
1 parent 8b912d2 commit 08bf6ec

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib/proxy.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ export function initProxyFromEnv(): void {
99
const direct = new Agent()
1010
const proxies = new Map<string, ProxyAgent>()
1111

12-
const dispatcher: Dispatcher = {
12+
// We only need a minimal dispatcher that implements `dispatch` at runtime.
13+
// Typing the object as `Dispatcher` forces TypeScript to require many
14+
// additional methods. Instead, keep a plain object and cast when passing
15+
// to `setGlobalDispatcher`.
16+
const dispatcher = {
1317
dispatch(
14-
options: Dispatcher.RequestOptions,
15-
handler: Dispatcher.DispatchHandlers,
18+
options: Dispatcher.DispatchOptions,
19+
handler: Dispatcher.DispatchHandler,
1620
) {
1721
try {
1822
const origin =
@@ -54,7 +58,7 @@ export function initProxyFromEnv(): void {
5458
},
5559
}
5660

57-
setGlobalDispatcher(dispatcher)
61+
setGlobalDispatcher(dispatcher as unknown as Dispatcher)
5862
consola.debug("HTTP proxy configured from environment (per-URL)")
5963
} catch (err) {
6064
consola.debug("Proxy setup skipped:", err)

0 commit comments

Comments
 (0)