Skip to content

Commit

Permalink
Fix nextPage typing in requests (#3298)
Browse files Browse the repository at this point in the history
The fixes the return type of the `nextPage()` method. Before, it would
return `Request<D, E>|void` which is hard to work with, because you
couldn't runtime test for `void` (everything can be void). This change
splits up the definition into two overloads: one without a callback
provided that returns `Request<D, E> | null` and a second for the
callback version that always returns `void`. This also matches the
documentation in the implementation now.

Co-authored-by: Michael Gruenewald <gruenem@amazon.com>
  • Loading branch information
siddsriv and Michael Gruenewald authored Sep 8, 2023
1 parent b5a2313 commit 7a04f0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-Paginator-887637f3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "Paginator",
"description": "Fix nextPage typing in requests"
}
3 changes: 2 additions & 1 deletion lib/response.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class Response<D, E> {
/**
* Creates a new request for the next page of response data, calling the callback with the page data if a callback is provided.
*/
nextPage(callback?: (err: E, data: D) => void): Request<D, E>|void;
nextPage(): Request<D, E> | null;
nextPage(callback: (err: E, data: D) => void): void;
/**
* The de-serialized response data from the service.
* Can be null if an error occurred.
Expand Down

0 comments on commit 7a04f0c

Please sign in to comment.