fix: relax fetch typing for Bun

This commit is contained in:
Peter Steinberger
2026-01-10 04:01:06 +01:00
parent 8466e53b5d
commit f241859c98
2 changed files with 9 additions and 4 deletions

View File

@@ -8,9 +8,14 @@ type FetchMediaResult = {
fileName?: string;
};
export type FetchLike = (
input: RequestInfo | URL,
init?: RequestInit,
) => Promise<Response>;
type FetchMediaOptions = {
url: string;
fetchImpl?: typeof fetch;
fetchImpl?: FetchLike;
filePathHint?: string;
};
@@ -57,7 +62,7 @@ export async function fetchRemoteMedia(
options: FetchMediaOptions,
): Promise<FetchMediaResult> {
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");
}