From d897dc83e8ce99e614977625f08f192fc8f4adaa Mon Sep 17 00:00:00 2001 From: Jan Chren ~rindeal Date: Mon, 9 Sep 2024 05:23:38 +0000 Subject: [PATCH] fix(types): add missing `cache` prop to RequestInit Also sort the props. See: https://github.com/nodejs/undici/blob/dca0aa0998cbdef28916b23d6300beb2fd979140/lib/web/fetch/request.js#L974-L979 --- test/types/fetch.test-d.ts | 20 +++++++++----------- types/fetch.d.ts | 17 +++++++++-------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/test/types/fetch.test-d.ts b/test/types/fetch.test-d.ts index 68d69c0f4ab..1bd2e63e6e8 100644 --- a/test/types/fetch.test-d.ts +++ b/test/types/fetch.test-d.ts @@ -38,23 +38,21 @@ declare const request: Request declare const headers: Headers declare const response: Response -expectType(requestInit.method) -expectType(requestInit.keepalive) -expectType(requestInit.headers) expectType(requestInit.body) -expectType(requestInit.redirect) -expectType(requestInit.integrity) -expectType(requestInit.signal) +expectType(requestInit4.body) +expectType(requestInit.cache) expectType(requestInit.credentials) +expectType(requestInit2.dispatcher) +expectType(requestInit.headers) +expectType(requestInit.integrity) +expectType(requestInit.keepalive) +expectType(requestInit.method) expectType(requestInit.mode) +expectType(requestInit.redirect) expectType(requestInit.referrer) expectType(requestInit.referrerPolicy) +expectType(requestInit.signal) expectType(requestInit.window) - -expectType(requestInit2.dispatcher) - -expectType(requestInit4.body) - expectType(responseInit.status) expectType(responseInit.statusText) expectType(responseInit.headers) diff --git a/types/fetch.d.ts b/types/fetch.d.ts index 7c2b1c98ccd..4edf41eb055 100644 --- a/types/fetch.d.ts +++ b/types/fetch.d.ts @@ -119,20 +119,21 @@ type RequestDestination = | 'xslt' export interface RequestInit { - method?: string - keepalive?: boolean - headers?: HeadersInit body?: BodyInit | null - redirect?: RequestRedirect - integrity?: string - signal?: AbortSignal | null + cache?: RequestCache credentials?: RequestCredentials + dispatcher?: Dispatcher + duplex?: RequestDuplex + headers?: HeadersInit + integrity?: string + keepalive?: boolean + method?: string mode?: RequestMode + redirect?: RequestRedirect referrer?: string referrerPolicy?: ReferrerPolicy + signal?: AbortSignal | null window?: null - dispatcher?: Dispatcher - duplex?: RequestDuplex } export type ReferrerPolicy =