@@ -14,14 +14,14 @@ import { z } from "zod";
14
14
interface RequestContext {
15
15
request : Request ;
16
16
controller : AbortController ;
17
- options : FetchOption ;
17
+ options : BetterFetchOption ;
18
18
}
19
19
20
20
interface ResponseContext {
21
21
response : Response ;
22
22
}
23
23
24
- export type BetterFetchOptions < B extends Record < string , any > = any > = {
24
+ export type BaseFetchOptions < B extends Record < string , any > = any > = {
25
25
/**
26
26
* a base url that will be prepended to the url
27
27
*/
@@ -103,22 +103,22 @@ export type BetterFetchOptions<B extends Record<string, any> = any> = {
103
103
* All plugins will be called before the request is made.
104
104
*/
105
105
export interface Plugin {
106
- ( url : string , options ?: FetchOption ) : Promise < {
106
+ ( url : string , options ?: BetterFetchOption ) : Promise < {
107
107
url : string ;
108
- options ?: FetchOption ;
108
+ options ?: BetterFetchOption ;
109
109
} > ;
110
110
}
111
111
112
112
// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
113
- export interface CreateFetchOption extends BetterFetchOptions { }
113
+ export interface CreateFetchOption extends BaseFetchOptions { }
114
114
115
115
export type PayloadMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" ;
116
116
export type NonPayloadMethod = "GET" | "HEAD" | "OPTIONS" ;
117
117
118
- export type FetchOption <
118
+ export type BetterFetchOption <
119
119
T extends Record < string , unknown > = any ,
120
120
Q extends Record < string , unknown > = any ,
121
- > = InferBody < T > & InferQuery < Q > & BetterFetchOptions ;
121
+ > = InferBody < T > & InferQuery < Q > & BaseFetchOptions ;
122
122
123
123
type InferBody < T > = T extends Record < string , any > ? { body : T } : { body ?: T } ;
124
124
type InferQuery < Q > = Q extends Record < string , any >
@@ -176,7 +176,7 @@ export const betterFetch: BetterFetch = async (url, options) => {
176
176
_url . searchParams . append ( key , String ( value ) ) ;
177
177
}
178
178
}
179
- const _options : FetchOption = {
179
+ const _options : BetterFetchOption = {
180
180
signal,
181
181
...options ,
182
182
body : shouldStringifyBody
@@ -327,16 +327,16 @@ export interface BetterFetch<
327
327
url : K | URL | Omit < string , keyof Routes > ,
328
328
...options : Routes [ K ] [ "input" ] extends z . Schema
329
329
? [
330
- FetchOption <
330
+ BetterFetchOption <
331
331
z . infer < Routes [ K ] [ "input" ] > ,
332
332
Routes [ K ] [ "query" ] extends z . ZodSchema
333
333
? z . infer < Routes [ K ] [ "query" ] >
334
334
: any
335
335
> ,
336
336
]
337
337
: Routes [ K ] [ "query" ] extends z . ZodSchema
338
- ? [ FetchOption < any , z . infer < Routes [ K ] [ "query" ] > > ]
339
- : [ FetchOption ?]
338
+ ? [ BetterFetchOption < any , z . infer < Routes [ K ] [ "query" ] > > ]
339
+ : [ BetterFetchOption ?]
340
340
) : Promise <
341
341
BetterFetchResponse <
342
342
Routes [ K ] [ "output" ] extends z . ZodSchema
0 commit comments