Skip to content

Commit

Permalink
🐛 FIX: Import undici types change (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Nov 25, 2022
1 parent 719628e commit 6a9dd92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/HttpAgent.ts
Expand Up @@ -3,15 +3,15 @@ import { LookupFunction, isIP } from 'net';
import {
Agent,
} from 'undici';
import { DispatchHandlers } from 'undici/types/dispatcher';
import { BuildOptions } from 'undici/types/connector';
import type Dispatcher from 'undici/types/dispatcher';
import type buildConnector from 'undici/types/connector';

export type CheckAddressFunction = (ip: string, family: number | string) => boolean;

export type HttpAgentOptions = {
lookup?: LookupFunction;
checkAddress?: CheckAddressFunction;
connect?: BuildOptions,
connect?: buildConnector.BuildOptions,
};

class IllegalAddressError extends Error {
Expand Down Expand Up @@ -51,7 +51,7 @@ export class HttpAgent extends Agent {
this.#checkAddress = options.checkAddress;
}

dispatch(options: Agent.DispatchOptions, handler: DispatchHandlers): boolean {
dispatch(options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean {
if (this.#checkAddress && options.origin) {
const originUrl = typeof options.origin === 'string' ? new URL(options.origin) : options.origin;
let hostname = originUrl.hostname;
Expand Down
5 changes: 1 addition & 4 deletions src/Request.ts
@@ -1,14 +1,11 @@
import { Readable, Writable } from 'stream';
import { IncomingHttpHeaders } from 'http';
import type {
HttpMethod as UndiciHttpMethod,
} from 'undici/types/dispatcher';
import type Dispatcher from 'undici/types/dispatcher';
import type {
HttpClientResponse,
} from './Response';

export type HttpMethod = UndiciHttpMethod;
export type HttpMethod = Dispatcher.HttpMethod;

export type RequestURL = string | URL;

Expand Down

0 comments on commit 6a9dd92

Please sign in to comment.