Skip to content

Commit 7a04f0c

Browse files
siddsrivMichael Gruenewald
andauthored
Fix nextPage typing in requests (#3298)
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 <[email protected]>
1 parent b5a2313 commit 7a04f0c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "bugfix",
3+
"category": "Paginator",
4+
"description": "Fix nextPage typing in requests"
5+
}

lib/response.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export class Response<D, E> {
88
/**
99
* Creates a new request for the next page of response data, calling the callback with the page data if a callback is provided.
1010
*/
11-
nextPage(callback?: (err: E, data: D) => void): Request<D, E>|void;
11+
nextPage(): Request<D, E> | null;
12+
nextPage(callback: (err: E, data: D) => void): void;
1213
/**
1314
* The de-serialized response data from the service.
1415
* Can be null if an error occurred.

0 commit comments

Comments
 (0)