From 8d48d99ac21bff1863de531782f6cfff29ebf373 Mon Sep 17 00:00:00 2001 From: Julian Hundeloh Date: Tue, 3 Mar 2020 12:56:59 +0100 Subject: [PATCH] fix: add GotPaginateOptions --- source/create.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/create.ts b/source/create.ts index 5e0a5b792..bfb664155 100644 --- a/source/create.ts +++ b/source/create.ts @@ -61,9 +61,11 @@ export interface GotRequestMethod { (url: string | Merge, options?: Merge): ProxyStream; } +export interface GotPaginateOptions = Omit> & PaginationOptions + export interface GotPaginate { - (url: URLOrOptions & PaginationOptions, options?: Omit> & PaginationOptions): AsyncIterableIterator; - all(url: URLOrOptions & PaginationOptions, options?: Omit> & PaginationOptions): Promise; + (url: string | GotPaginateOptions, options?: GotPaginateOptions): AsyncIterableIterator; + all(url: string | GotPaginateOptions, options?: GotPaginateOptions): Promise; } export interface Got extends Record, GotRequestMethod { @@ -198,8 +200,8 @@ const create = (defaults: Defaults): Got => { } // @ts-ignore The missing property is added below - got.paginate = async function * (url: URLOrOptions, options?: Omit> & PaginationOptions) { - let normalizedOptions = normalizeArguments(url, options as Options, defaults); + got.paginate = async function * (url: string | Omit> & PaginationOptions, options?: Omit> & PaginationOptions) { + let normalizedOptions = normalizeArguments(url as URLOrOptions, options as Options, defaults); const pagination = normalizedOptions._pagination!; @@ -245,7 +247,7 @@ const create = (defaults: Defaults): Got => { } }; - got.paginate.all = async (url: URLOrOptions, options?: Omit> & PaginationOptions) => { + got.paginate.all = async (url: string | GotPaginateOptions, options?: GotPaginateOptions) => { const results: T[] = []; for await (const item of got.paginate(url, options)) {