Skip to content

Commit

Permalink
export interceptor to type def file (#3318)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
jakecastelli and jake li authored Jun 12, 2024
1 parent f9997bb commit 1e508d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/imports/undici-import.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { request } from '../../'
import { interceptors } from '../../'

async function exampleCode() {
const retry = interceptors.retry()
const rd = interceptors.redirect()
const dump = interceptors.dump()

await request('http://localhost:3000/foo')
}
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import EnvHttpProxyAgent from './env-http-proxy-agent'
import RetryHandler from'./retry-handler'
import RetryAgent from'./retry-agent'
import { request, pipeline, stream, connect, upgrade } from './api'
import interceptors from './interceptors'

export * from './util'
export * from './cookies'
Expand All @@ -32,7 +33,7 @@ export * from './content-type'
export * from './cache'
export { Interceptable } from './mock-interceptor'

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 }
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 }
export default Undici

declare namespace Undici {
Expand Down

0 comments on commit 1e508d7

Please sign in to comment.