Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: interceptors.d.ts has no default export #3332

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint is throwing typings errors. to avoid it we simulate an skipLibCheck by pointing to the types folder. this is not nice but eslint sucks. So this is a low level solution.

"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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was unused import


/**
* 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsc reported that after optional paramaters there can not be mandatory parameters.

Compared with implementation and the following arguments are not existing.

): number

/**
Expand Down
Loading