Fix types

This commit is contained in:
SukkaW
2024-10-15 17:39:12 +08:00
parent b742701f59
commit 824fde2fc0
3 changed files with 11 additions and 9 deletions

View File

@@ -11,7 +11,7 @@ import { stringHash } from './string-hash';
import { defaultRequestInit, fetchWithLog } from './fetch-retry';
import { Custom304NotModifiedError, CustomAbortError, CustomNoETagFallbackError, fetchAssets, sleepWithAbort } from './fetch-assets';
import type { Response, RequestInit } from 'undici';
import type { Response, RequestInit, HeadersInit } from 'undici';
const enum CacheStatus {
Hit = 'hit',
@@ -329,9 +329,9 @@ export class Cache<S = string> {
signal: controller.signal,
...defaultRequestInit,
headers: (typeof etag === 'string' && etag.length > 0)
? mergeHeaders(
defaultRequestInit.headers,
{ 'If-None-Match': etag }
? mergeHeaders<HeadersInit>(
{ 'If-None-Match': etag },
defaultRequestInit.headers
)
: defaultRequestInit.headers
}

View File

@@ -133,7 +133,7 @@ export class ResponseError extends Error {
}
}
export const defaultRequestInit: RequestInit = {
export const defaultRequestInit = {
headers: {
'User-Agent': 'curl/8.9.1 (https://github.com/SukkaW/Surge)'
}