From 14de999bb9d19c7142f22771a6dad568c994abf1 Mon Sep 17 00:00:00 2001 From: Michael Gruenewald Date: Tue, 9 Jun 2020 15:04:46 +0200 Subject: [PATCH] Fix nextPage typing in requests The fixes the return type of the `nextPage()` method. Before, it would return `Request|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 | null` and a second for the callback version that always returns `void`. This also matches the documentation in the implementation now. --- .changes/next-release/bugfix-Paginator-887637f3.json | 5 +++++ lib/response.d.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/next-release/bugfix-Paginator-887637f3.json diff --git a/.changes/next-release/bugfix-Paginator-887637f3.json b/.changes/next-release/bugfix-Paginator-887637f3.json new file mode 100644 index 0000000000..2ec92164d3 --- /dev/null +++ b/.changes/next-release/bugfix-Paginator-887637f3.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "Paginator", + "description": "Fix nextPage typing in requests" +} \ No newline at end of file diff --git a/lib/response.d.ts b/lib/response.d.ts index cfbddc00bd..a95a7d3190 100644 --- a/lib/response.d.ts +++ b/lib/response.d.ts @@ -8,7 +8,8 @@ export class Response { /** * 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|void; + nextPage(): Request | null; + nextPage(callback: (err: E, data: D) => void): void; /** * The de-serialized response data from the service. * Can be null if an error occurred.