Skip to content

Commit

Permalink
fix(types): ensure that only the paginated response is retured
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Sep 27, 2024
1 parent eb6b361 commit 123cf0c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ type GetResultsType<T> = T extends { data: any[] }
? T["data"][KnownKeysMatching<T["data"], any[]>]
: never;

type NormalizeResponse<T> = T & { data: GetResultsType<T> };
// Ensure that the type always returns the paginated results and not a mix of paginated results and the response object
type NormalizeResponse<T> = Omit<T, 'data'> & { data: GetResultsType<T> };

type DataType<T> = "data" extends keyof T ? T["data"] : unknown;

Expand Down

0 comments on commit 123cf0c

Please sign in to comment.