Skip to content

Commit 1e508d7

Browse files
jakecastellijake li
andauthored
export interceptor to type def file (#3318)
* export interceptor to type def file Fixes: #3308 * fixup! add a test * fixup! add retry, redirect, dump and remove createRedirectInterceptor --------- Co-authored-by: jake li <[email protected]>
1 parent f9997bb commit 1e508d7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

test/imports/undici-import.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { request } from '../../'
2+
import { interceptors } from '../../'
23

34
async function exampleCode() {
5+
const retry = interceptors.retry()
6+
const rd = interceptors.redirect()
7+
const dump = interceptors.dump()
8+
49
await request('http://localhost:3000/foo')
510
}

types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import EnvHttpProxyAgent from './env-http-proxy-agent'
1818
import RetryHandler from'./retry-handler'
1919
import RetryAgent from'./retry-agent'
2020
import { request, pipeline, stream, connect, upgrade } from './api'
21+
import interceptors from './interceptors'
2122

2223
export * from './util'
2324
export * from './cookies'
@@ -32,7 +33,7 @@ export * from './content-type'
3233
export * from './cache'
3334
export { Interceptable } from './mock-interceptor'
3435

35-
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent }
36+
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent }
3637
export default Undici
3738

3839
declare namespace Undici {

0 commit comments

Comments
 (0)