From a235e2067402dfece6886c0a4ad84c2567a12698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=81=C4=85giewka?= Date: Wed, 22 Jan 2025 17:24:10 +0100 Subject: [PATCH 1/2] fix(types): add missing DNS interceptor #3684 has backported the DNS interceptor from #3490. However, the func that is exported, was not added to TypeScript defs. Co-authored-by: Carlos Fuentes --- types/interceptors.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/interceptors.d.ts b/types/interceptors.d.ts index 65e9397554e..9f6af128d5e 100644 --- a/types/interceptors.d.ts +++ b/types/interceptors.d.ts @@ -28,4 +28,5 @@ declare namespace Interceptors { export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor export function responseError(opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor + export function dns (opts?: DNSInterceptorOpts): Dispatcher.DispatcherComposeInterceptor } From 8d78fb058a3cdd666a281f9a570f74ace8838db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=81=C4=85giewka?= Date: Thu, 23 Jan 2025 08:55:19 +0100 Subject: [PATCH 2/2] add DNS interceptor type test --- test/types/interceptor.test-d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/types/interceptor.test-d.ts b/test/types/interceptor.test-d.ts index ba242bfcadb..3a09fc290a4 100644 --- a/test/types/interceptor.test-d.ts +++ b/test/types/interceptor.test-d.ts @@ -1,5 +1,9 @@ import {expectAssignable} from "tsd"; import Undici from "../.."; import Dispatcher from "../../types/dispatcher"; +import Interceptors from "../../types/interceptors"; expectAssignable(Undici.createRedirectInterceptor({ maxRedirections: 3 })) + +expectAssignable(new Dispatcher().compose([Interceptors.dns({maxTTL: 2_000})])); +