Skip to content

Commit 43fb162

Browse files
authored
feat: add install() function to type definitions (#4384)
1 parent e5bf00e commit 43fb162

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

test/types/index.test-d.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
import { expectAssignable } from 'tsd'
2-
import Undici, { Pool, Client, errors, fetch, Interceptable, RedirectHandler, Headers, Response, Request, FormData, SnapshotAgent } from '../..'
1+
import { expectAssignable, expectType } from 'tsd'
2+
import Undici, {
3+
Pool,
4+
Client,
5+
errors,
6+
fetch,
7+
Interceptable,
8+
RedirectHandler,
9+
Headers,
10+
Response,
11+
Request,
12+
FormData,
13+
SnapshotAgent,
14+
install
15+
} from '../..'
316
import Dispatcher from '../../types/dispatcher'
417

518
expectAssignable<Pool>(new Undici.Pool('', {}))
@@ -24,3 +37,6 @@ const redirectHandler = new Undici.RedirectHandler(dispatcher.dispatch, 10, {
2437
path: '/', method: 'GET'
2538
}, handler, false) as RedirectHandler
2639
expectAssignable<RedirectHandler>(redirectHandler)
40+
41+
expectType<() => void>(install)
42+
expectType<() => void>(Undici.install)

types/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export * from './content-type'
3434
export * from './cache'
3535
export { Interceptable } from './mock-interceptor'
3636

37-
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, SnapshotAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient }
37+
declare function globalThisInstall (): void
38+
39+
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, MockClient, MockPool, MockAgent, SnapshotAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient, globalThisInstall as install }
3840
export default Undici
3941

4042
declare namespace Undici {
@@ -74,4 +76,5 @@ declare namespace Undici {
7476
MemoryCacheStore: typeof import('./cache-interceptor').default.MemoryCacheStore,
7577
SqliteCacheStore: typeof import('./cache-interceptor').default.SqliteCacheStore
7678
}
79+
const install: typeof globalThisInstall
7780
}

0 commit comments

Comments
 (0)