type Fetch = typeof globalThis.fetch; type RequestInfo = globalThis.RequestInfo; type RequestInit = globalThis.RequestInit; type Response = globalThis.Response; interface ResponseMap { blob: Blob; text: string; arrayBuffer: ArrayBuffer; stream: ReadableStream; } type ResponseType = keyof ResponseMap | "json"; type MappedType = R extends keyof ResponseMap ? ResponseMap[R] : JsonType; interface CreateFetchOptions { defaults?: FetchOptions; fetch: Fetch; Headers: typeof Headers; } type FetchRequest = RequestInfo; interface FetchResponse extends Response { _data?: T; } interface SearchParameters { [key: string]: any; } interface FetchContext { request: FetchRequest; options: FetchOptions; response?: FetchResponse; error?: Error; } interface FetchOptions extends Omit { baseURL?: string; body?: RequestInit["body"] | Record; ignoreResponseError?: boolean; params?: SearchParameters; query?: SearchParameters; parseResponse?: (responseText: string) => any; responseType?: R; response?: boolean; retry?: number | false; onRequest?(context: FetchContext): Promise | void; onRequestError?(context: FetchContext & { error: Error; }): Promise | void; onResponse?(context: FetchContext & { response: FetchResponse; }): Promise | void; onResponseError?(context: FetchContext & { response: FetchResponse; }): Promise | void; } interface $Fetch { (request: FetchRequest, options?: FetchOptions): Promise>; raw(request: FetchRequest, options?: FetchOptions): Promise>>; native: Fetch; create(defaults: FetchOptions): $Fetch; } declare function createFetch(globalOptions: CreateFetchOptions): $Fetch; declare class FetchError extends Error { name: string; request?: FetchRequest; response?: FetchResponse; data?: T; status?: number; statusText?: string; statusCode?: number; statusMessage?: string; } declare function createFetchError(request: FetchRequest, error?: Error, response?: FetchResponse): FetchError; export { $Fetch as $, CreateFetchOptions as C, FetchRequest as F, SearchParameters as S, FetchResponse as a, FetchContext as b, FetchOptions as c, createFetch as d, FetchError as e, createFetchError as f };