@@ -2,14 +2,14 @@ import type { Server } from "@hapi/hapi";
22import type {
33 AvailablePaths ,
44 FetchOptions ,
5- HasRequiredFields ,
65 MatchingRoute ,
76 RequestMethod ,
87 ResponseType ,
98 BodyType ,
109 Route ,
1110 Simplify ,
1211 StatusCode ,
12+ OptionsArgument ,
1313} from "./types.ts" ;
1414
1515export type * from "./types.ts" ;
@@ -21,7 +21,7 @@ export type ClientOptions = Simplify<
2121> ;
2222
2323export class Client < T extends Route > {
24- #url: URL ;
24+ #url: URL | undefined ;
2525 #server: Server | undefined ;
2626 #headers: Headers ;
2727
@@ -121,47 +121,47 @@ export class Client<T extends Route> {
121121 P extends AvailablePaths < T , "DELETE" > ,
122122 R extends MatchingRoute < T , "DELETE" , P > ,
123123 O extends FetchOptions < R > ,
124- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
124+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
125125 return await this . #fetch( "DELETE" , path , args [ 0 ] ) ;
126126 }
127127
128128 async get <
129129 P extends AvailablePaths < T , "GET" > ,
130130 R extends MatchingRoute < T , "GET" , P > ,
131131 O extends FetchOptions < R > ,
132- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
132+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
133133 return await this . #fetch( "GET" , path , args [ 0 ] ) ;
134134 }
135135
136136 async options <
137137 P extends AvailablePaths < T , "OPTIONS" > ,
138138 R extends MatchingRoute < T , "OPTIONS" , P > ,
139139 O extends FetchOptions < R > ,
140- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
140+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
141141 return await this . #fetch( "OPTIONS" , path , args [ 0 ] ) ;
142142 }
143143
144144 async patch <
145145 P extends AvailablePaths < T , "PATCH" > ,
146146 R extends MatchingRoute < T , "PATCH" , P > ,
147147 O extends FetchOptions < R > ,
148- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
148+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
149149 return await this . #fetch( "PATCH" , path , args [ 0 ] ) ;
150150 }
151151
152152 async post <
153153 P extends AvailablePaths < T , "POST" > ,
154154 R extends MatchingRoute < T , "POST" , P > ,
155155 O extends FetchOptions < R > ,
156- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
156+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
157157 return await this . #fetch( "POST" , path , args [ 0 ] ) ;
158158 }
159159
160160 async put <
161161 P extends AvailablePaths < T , "PUT" > ,
162162 R extends MatchingRoute < T , "PUT" , P > ,
163163 O extends FetchOptions < R > ,
164- > ( path : P , ...args : ( HasRequiredFields < O > extends true ? [ O ] : [ O ? ] ) ) : Promise < ResponseType < R > > {
164+ > ( path : P , ...args : OptionsArgument < O > ) : Promise < ResponseType < R > > {
165165 return await this . #fetch( "PUT" , path , args [ 0 ] ) ;
166166 }
167167}
0 commit comments