From ae2442263d8c1ac5631c3e0c629e9ebaaf2848fa Mon Sep 17 00:00:00 2001 From: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com> Date: Tue, 18 Aug 2026 12:55:11 +0000 Subject: [PATCH] types: export PendingInterceptor and PendingInterceptorsFormatter from MockAgent Both interfaces were declared at the top level of the module and never exported, so a consumer typing a helper around pendingInterceptors() had no way to name their argument and had to copy the declaration, which then drifts. Move them under the MockAgent namespace and point the two members at the namespaced names. --- test/types/mock-agent.test-d.ts | 16 ++++++++++++++++ types/mock-agent.d.ts | 21 +++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/test/types/mock-agent.test-d.ts b/test/types/mock-agent.test-d.ts index fc4ddd6221b..5e9949af13f 100644 --- a/test/types/mock-agent.test-d.ts +++ b/test/types/mock-agent.test-d.ts @@ -78,6 +78,22 @@ expectAssignable(new MockAgent({})) format(pendingInterceptors: readonly PendingInterceptor[]): string; } }) => void>(agent.assertNoPendingInterceptors) + + // the same types have to be reachable from outside the package + expectAssignable({ + origin: 'http://localhost', + path: '/', + method: 'GET', + data: { error: null, statusCode: 200, data: '', headers: {}, trailers: {} }, + consumed: false, + times: null, + persist: false + }) + expectAssignable({ + format (pendingInterceptors: readonly MockAgent.PendingInterceptor[]): string { + return String(pendingInterceptors.length) + } + }) } // issue #3444 diff --git a/types/mock-agent.d.ts b/types/mock-agent.d.ts index 330926be191..c718df1a433 100644 --- a/types/mock-agent.d.ts +++ b/types/mock-agent.d.ts @@ -6,10 +6,6 @@ import { MockCallHistory } from './mock-call-history' export default MockAgent -interface PendingInterceptor extends MockDispatch { - origin: string; -} - /** A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead. */ declare class MockAgent extends Dispatcher { constructor (options?: TMockAgentOptions) @@ -40,17 +36,22 @@ declare class MockAgent