diff --git a/src/media/fetch.ts b/src/media/fetch.ts index 55d15a63d..367a8b7bc 100644 --- a/src/media/fetch.ts +++ b/src/media/fetch.ts @@ -8,9 +8,14 @@ type FetchMediaResult = { fileName?: string; }; +export type FetchLike = ( + input: RequestInfo | URL, + init?: RequestInit, +) => Promise; + type FetchMediaOptions = { url: string; - fetchImpl?: typeof fetch; + fetchImpl?: FetchLike; filePathHint?: string; }; @@ -57,7 +62,7 @@ export async function fetchRemoteMedia( options: FetchMediaOptions, ): Promise { const { url, fetchImpl, filePathHint } = options; - const fetcher = fetchImpl ?? globalThis.fetch; + const fetcher: FetchLike | undefined = fetchImpl ?? globalThis.fetch; if (!fetcher) { throw new Error("fetch is not available"); } diff --git a/src/slack/monitor.ts b/src/slack/monitor.ts index 62278e899..11a8a17ce 100644 --- a/src/slack/monitor.ts +++ b/src/slack/monitor.ts @@ -45,7 +45,7 @@ import { import { danger, logVerbose, shouldLogVerbose } from "../globals.js"; import { enqueueSystemEvent } from "../infra/system-events.js"; import { getChildLogger } from "../logging.js"; -import { fetchRemoteMedia } from "../media/fetch.js"; +import { fetchRemoteMedia, type FetchLike } from "../media/fetch.js"; import { saveMediaBuffer } from "../media/store.js"; import { buildPairingReply } from "../pairing/pairing-messages.js"; import { @@ -355,7 +355,7 @@ async function resolveSlackMedia(params: { const url = file.url_private_download ?? file.url_private; if (!url) continue; try { - const fetchImpl: typeof fetch = (input, init) => { + const fetchImpl: FetchLike = (input, init) => { const headers = new Headers(init?.headers); headers.set("Authorization", `Bearer ${params.token}`); return fetch(input, { ...init, headers });