@@ -60,14 +60,35 @@ export interface GetRequest extends RequestOptions {
6060 body ?: never ;
6161}
6262
63- export type RequestWithoutBody = HeadRequest | GetRequest ;
64-
65- export interface RequestWithBody extends Omit < RequestOptions , 'body' > {
66- method ?: 'POST' | 'PUT' | 'PATCH' | 'DELETE' ;
63+ interface WithBody extends Omit < RequestOptions , 'body' > {
6764 body ?: FetcherRequestInit [ 'body' ] | object ;
6865}
6966
70- type DataSourceRequest = RequestWithoutBody | RequestWithBody ;
67+ export interface PostRequest extends WithBody {
68+ method ?: 'POST' ;
69+ }
70+
71+ export interface PutRequest extends WithBody {
72+ method ?: 'PUT' ;
73+ }
74+
75+ export interface PatchRequest extends WithBody {
76+ method ?: 'PATCH' ;
77+ }
78+
79+ export interface DeleteRequest extends WithBody {
80+ method ?: 'DELETE' ;
81+ }
82+
83+ export type RequestWithoutBody = HeadRequest | GetRequest ;
84+
85+ export type RequestWithBody =
86+ | PostRequest
87+ | PutRequest
88+ | PatchRequest
89+ | DeleteRequest ;
90+
91+ export type DataSourceRequest = RequestWithoutBody | RequestWithBody ;
7192
7293// While tempting, this union can't be reduced / factored out to just
7394// Omit<WithRequired<RequestWithBody | RequestWithBody, 'headers'>, 'params'> & { params: URLSearchParams }
@@ -366,7 +387,7 @@ export abstract class RESTDataSource {
366387
367388 protected async post < TResult = any > (
368389 path : string ,
369- request ?: RequestWithBody ,
390+ request ?: PostRequest ,
370391 ) : Promise < TResult > {
371392 return (
372393 await this . fetch < TResult > ( path , {
@@ -378,7 +399,7 @@ export abstract class RESTDataSource {
378399
379400 protected async patch < TResult = any > (
380401 path : string ,
381- request ?: RequestWithBody ,
402+ request ?: PatchRequest ,
382403 ) : Promise < TResult > {
383404 return (
384405 await this . fetch < TResult > ( path , {
@@ -390,7 +411,7 @@ export abstract class RESTDataSource {
390411
391412 protected async put < TResult = any > (
392413 path : string ,
393- request ?: RequestWithBody ,
414+ request ?: PutRequest ,
394415 ) : Promise < TResult > {
395416 return (
396417 await this . fetch < TResult > ( path , {
@@ -402,7 +423,7 @@ export abstract class RESTDataSource {
402423
403424 protected async delete < TResult = any > (
404425 path : string ,
405- request ?: RequestWithBody ,
426+ request ?: DeleteRequest ,
406427 ) : Promise < TResult > {
407428 return (
408429 await this . fetch < TResult > ( path , {
0 commit comments