Skip to content

Commit

Permalink
fix: add value type of done result
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 10, 2023
1 parent 913ef3e commit f809cbd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Paginator<Entity, Params = never>
private nextParams?: Params,
) {}

async next(): Promise<IteratorResult<Entity>> {
async next(): Promise<IteratorResult<Entity, undefined>> {
if (this.nextPath == undefined) {
return { done: true, value: undefined };
}
Expand Down Expand Up @@ -52,10 +52,15 @@ export class Paginator<Entity, Params = never>
reason: unknown,
) => TResult2 | PromiseLike<TResult2> = Promise.reject,
): Promise<TResult1 | TResult2> {
return this.next().then((value) => onfulfilled(value.value), onrejected);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return this.next().then((value) => onfulfilled(value.value!), onrejected);
}

[Symbol.asyncIterator](): AsyncGenerator<Entity, Entity, Params | undefined> {
[Symbol.asyncIterator](): AsyncGenerator<
Entity,
undefined,
Params | undefined
> {
return this;
}

Expand Down

0 comments on commit f809cbd

Please sign in to comment.