File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,13 @@ export interface $Fetch<
78
78
> (
79
79
request : R ,
80
80
opts ?: O
81
- ) : Promise < TypedInternalResponse < R , T , ExtractedRouteMethod < R , O > > > ;
81
+ ) : Promise <
82
+ TypedInternalResponse <
83
+ R ,
84
+ T ,
85
+ NitroFetchOptions < R > extends O ? "get" : ExtractedRouteMethod < R , O >
86
+ >
87
+ > ;
82
88
raw <
83
89
T = DefaultT ,
84
90
R extends NitroFetchRequest = DefaultR ,
@@ -87,7 +93,13 @@ export interface $Fetch<
87
93
request : R ,
88
94
opts ?: O
89
95
) : Promise <
90
- FetchResponse < TypedInternalResponse < R , T , ExtractedRouteMethod < R , O > > >
96
+ FetchResponse <
97
+ TypedInternalResponse <
98
+ R ,
99
+ T ,
100
+ NitroFetchOptions < R > extends O ? "get" : ExtractedRouteMethod < R , O >
101
+ >
102
+ >
91
103
> ;
92
104
create < T = DefaultT , R extends NitroFetchRequest = DefaultR > (
93
105
defaults : FetchOptions
Original file line number Diff line number Diff line change @@ -183,6 +183,13 @@ describe("API routes", () => {
183
183
} ) ;
184
184
185
185
it ( "generates the correct type depending on the method used" , ( ) => {
186
+ expectTypeOf ( $fetch ( "/api/methods" ) ) . toEqualTypeOf < Promise < "Index get" > > ( ) ;
187
+ expectTypeOf ( $fetch ( "/api/methods" , { } ) ) . toEqualTypeOf <
188
+ Promise < "Index get" >
189
+ > ( ) ;
190
+ expectTypeOf ( $fetch ( "/api/methods" , { query : { } } ) ) . toEqualTypeOf <
191
+ Promise < "Index get" >
192
+ > ( ) ;
186
193
expectTypeOf ( $fetch ( "/api/methods" , { method : "get" } ) ) . toEqualTypeOf <
187
194
Promise < "Index get" >
188
195
> ( ) ;
You can’t perform that action at this time.
0 commit comments