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