Skip to content

Commit 85d614f

Browse files
committed
fix: correct type references in API handler and request handler for consistency
1 parent 072bd21 commit 85d614f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ interface AddBookRequest {
22352235
body: AddBookRequestBody;
22362236
}
22372237
2238-
const { data: bookAddedData } = await fetchff<AddBookRequest>('/api/add-book', {
2238+
const { data: bookAddedData } = await fetchf<AddBookRequest>('/api/add-book', {
22392239
method: 'POST',
22402240
});
22412241
// Your bookAddedData is of type AddBookResponseData

src/types/api-handler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export type Endpoint<T extends DefaultRequestTypes = DefaultRequestTypes> =
7474

7575
// Helper to support 4 generics
7676
export type EndpointReq<
77-
ResponseData = DefaultResponse,
78-
RequestBody = DefaultPayload,
79-
QueryParams = DefaultParams,
80-
UrlPathParams = DefaultUrlParams,
77+
ResponseData extends DefaultResponse | undefined = DefaultResponse,
78+
RequestBody extends DefaultPayload | undefined = DefaultPayload,
79+
QueryParams extends DefaultParams | undefined = DefaultParams,
80+
UrlPathParams extends DefaultUrlParams | undefined = DefaultUrlParams,
8181
> = Endpoint<Req<ResponseData, RequestBody, QueryParams, UrlPathParams>>;
8282

8383
type MergeEndpointShape<

src/types/request-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export type Req<
6767

6868
export type DefaultRequestTypes = {
6969
response?: DefaultResponse;
70-
body?: BodyPayload;
70+
body?: DefaultPayload;
7171
params?: QueryParams;
7272
urlPathParams?: UrlPathParams;
7373
};

0 commit comments

Comments
 (0)