Skip to content
Open
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
14 changes: 7 additions & 7 deletions src/lib/models.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { RetryConfiguration } from "./retry.js";
import { Dispatcher } from "undici-types";
import type { Dispatcher } from "undici-types";

/**
* @private
*/
export type FetchAPI = (url: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
export type FetchAPI = (url: string | URL | Request, init?: RequestInit) => Promise<Response>;

export interface ClientOptions extends Omit<Configuration, "baseUrl" | "parseError" | "middleware"> {
telemetry?: boolean;
Expand Down Expand Up @@ -56,12 +56,12 @@
[key: string]: string | number | null | boolean | Array<string | number | null | boolean> | HTTPQuery;
};

export type HTTPBody = any | FormData | URLSearchParams;

Check warning on line 59 in src/lib/models.ts

View workflow job for this annotation

GitHub Actions / Lint & Format

Unexpected any. Specify a different type

Check warning on line 59 in src/lib/models.ts

View workflow job for this annotation

GitHub Actions / Type Check

Unexpected any. Specify a different type

export type HTTPRequestInit = {
headers?: HTTPHeaders;
method: HTTPMethod;
credentials?: RequestCredentials;
credentials?: "include" | "omit" | "same-origin";
body?: HTTPBody;
};

Expand Down Expand Up @@ -120,26 +120,26 @@
}

export interface FetchParams {
url: URL | RequestInfo;
url: string | URL | Request;
init: RequestInit;
}

export interface RequestContext {
fetch: FetchAPI;
url: URL | RequestInfo;
url: string | URL | Request;
init: RequestInit;
}

export interface ResponseContext {
fetch: FetchAPI;
url: URL | RequestInfo;
url: string | URL | Request;
init: RequestInit;
response: Response;
}

export interface ErrorContext {
fetch: FetchAPI;
url: URL | RequestInfo;
url: string | URL | Request;
init: RequestInit;
error: unknown;
response?: Response;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
}, this.timeoutDuration);
try {
return await this.fetchApi(url, { signal: controller.signal as AbortSignal, ...init });
} catch (e: any) {

Check warning on line 95 in src/lib/runtime.ts

View workflow job for this annotation

GitHub Actions / Lint & Format

Unexpected any. Specify a different type

Check warning on line 95 in src/lib/runtime.ts

View workflow job for this annotation

GitHub Actions / Type Check

Unexpected any. Specify a different type
if (e.name === "AbortError") {
throw new TimeoutError();
}
Expand All @@ -102,7 +102,7 @@
}
};

private fetch = async (url: URL | RequestInfo, init: RequestInit) => {
private fetch = async (url: string | URL | Request, init: RequestInit) => {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
Expand Down
Loading