Skip to content

Commit

Permalink
fix: interceptors.d.ts has no default export (#3332)
Browse files Browse the repository at this point in the history
* fix: types interceptors default export

* test for bugs in typescript
  • Loading branch information
Uzlopak authored Jun 18, 2024
1 parent 5dadb95 commit a7441d8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"test:node-test": "borp -p \"test/node-test/**/*.js\"",
"test:tdd": "borp --expose-gc -p \"test/*.js\"",
"test:tdd:node-test": "borp -p \"test/node-test/**/*.js\" -w",
"test:typescript": "tsd && tsc --skipLibCheck test/imports/undici-import.ts",
"test:typescript": "tsd && tsc test/imports/undici-import.ts --typeRoots ./types && tsc ./types/*.d.ts --noEmit --typeRoots ./types",
"test:webidl": "borp -p \"test/webidl/*.js\"",
"test:websocket": "borp -p \"test/websocket/*.js\"",
"test:websocket:autobahn": "node test/autobahn/client.js",
Expand Down
2 changes: 1 addition & 1 deletion types/formdata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference types="node" />

import { File } from './file'
import { SpecIterator, SpecIterableIterator } from './fetch'
import { SpecIterableIterator } from './fetch'

/**
* A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
Expand Down
8 changes: 2 additions & 6 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare namespace Undici {
var RedirectHandler: typeof import ('./handlers').RedirectHandler
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
var RetryHandler: typeof import ('./retry-handler').default
var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor
var createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
var BalancedPool: typeof import('./balanced-pool').default;
var Client: typeof import('./client').default;
var buildConnector: typeof import('./connector').default;
Expand All @@ -67,9 +67,5 @@ declare namespace Undici {
var File: typeof import('./file').File;
var FileReader: typeof import('./filereader').FileReader;
var caches: typeof import('./cache').caches;
var interceptors: {
dump: typeof import('./interceptors').dump;
retry: typeof import('./interceptors').retry;
redirect: typeof import('./interceptors').redirect;
}
var interceptors: typeof import('./interceptors').default;
}
18 changes: 11 additions & 7 deletions types/interceptors.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Dispatcher from "./dispatcher";
import RetryHandler from "./retry-handler";

export type DumpInterceptorOpts = { maxSize?: number }
export type RetryInterceptorOpts = RetryHandler.RetryOptions
export type RedirectInterceptorOpts = { maxRedirections?: number }
export default Interceptors;

export declare function createRedirectInterceptor (opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export declare function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export declare function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export declare function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
declare namespace Interceptors {
export type DumpInterceptorOpts = { maxSize?: number }
export type RetryInterceptorOpts = RetryHandler.RetryOptions
export type RedirectInterceptorOpts = { maxRedirections?: number }

export function createRedirectInterceptor(opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function dump(opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function retry(opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
export function redirect(opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
}
3 changes: 0 additions & 3 deletions types/retry-agent.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import Agent from './agent'
import buildConnector from './connector';
import Dispatcher from './dispatcher'
import { IncomingHttpHeaders } from './header'
import RetryHandler from './retry-handler'

export default RetryAgent
Expand Down
4 changes: 1 addition & 3 deletions types/webidl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ interface WebidlUtil {
V: unknown,
bitLength: number,
signedness: 'signed' | 'unsigned',
opts?: ConvertToIntOpts,
prefix: string,
argument: string
opts?: ConvertToIntOpts
): number

/**
Expand Down

0 comments on commit a7441d8

Please sign in to comment.