From c2146086e3c7a11f0cdf0cde968d19fca98e2d4b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 21:22:46 +0000 Subject: [PATCH] feat(typescript): make response property public and typed in pagination - Updated Page class to accept a second generic parameter R for response type - Changed response property from private to public - Response property is now properly typed instead of using 'unknown' or 'any' - Updated Pageable class to pass response type to parent Page class - Maintains backward compatibility with R = unknown default Co-Authored-By: thomas@buildwithfern.com --- .../src/core/pagination/Page.ts | 19 ++++++++++--------- .../src/core/pagination/Pageable.ts | 4 ++-- .../pagination/src/core/pagination/Page.ts | 19 ++++++++++--------- .../src/core/pagination/Pageable.ts | 6 +----- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/generators/typescript/utils/core-utilities/src/core/pagination/Page.ts b/generators/typescript/utils/core-utilities/src/core/pagination/Page.ts index 15f64bef32c5..b7e94c2788d1 100644 --- a/generators/typescript/utils/core-utilities/src/core/pagination/Page.ts +++ b/generators/typescript/utils/core-utilities/src/core/pagination/Page.ts @@ -4,15 +4,16 @@ import { HttpResponsePromise, type RawResponse } from "../fetcher/index"; * A page of results from a paginated API. * * @template T The type of the items in the page. + * @template R The type of the response object. */ -export class Page implements AsyncIterable { +export class Page implements AsyncIterable { public data: T[]; public rawResponse: RawResponse; + public response: R; - private response: unknown; - private _hasNextPage: (response: unknown) => boolean; - private getItems: (response: unknown) => T[]; - private loadNextPage: (response: unknown) => HttpResponsePromise; + private _hasNextPage: (response: R) => boolean; + private getItems: (response: R) => T[]; + private loadNextPage: (response: R) => HttpResponsePromise; constructor({ response, @@ -21,11 +22,11 @@ export class Page implements AsyncIterable { getItems, loadPage }: { - response: unknown; + response: R; rawResponse: RawResponse; - hasNextPage: (response: unknown) => boolean; - getItems: (response: unknown) => T[]; - loadPage: (response: unknown) => HttpResponsePromise; + hasNextPage: (response: R) => boolean; + getItems: (response: R) => T[]; + loadPage: (response: R) => HttpResponsePromise; }) { this.response = response; this.rawResponse = rawResponse; diff --git a/generators/typescript/utils/core-utilities/src/core/pagination/Pageable.ts b/generators/typescript/utils/core-utilities/src/core/pagination/Pageable.ts index 162c9ceae573..500392e080c8 100644 --- a/generators/typescript/utils/core-utilities/src/core/pagination/Pageable.ts +++ b/generators/typescript/utils/core-utilities/src/core/pagination/Pageable.ts @@ -11,8 +11,8 @@ export declare namespace Pageable { } } -export class Pageable extends Page { +export class Pageable extends Page { constructor(args: Pageable.Args) { - super(args as any); + super(args); } } diff --git a/seed/ts-sdk/pagination/src/core/pagination/Page.ts b/seed/ts-sdk/pagination/src/core/pagination/Page.ts index 1aa08e568fad..e710dcdc4255 100644 --- a/seed/ts-sdk/pagination/src/core/pagination/Page.ts +++ b/seed/ts-sdk/pagination/src/core/pagination/Page.ts @@ -4,15 +4,16 @@ import type { HttpResponsePromise, RawResponse } from "../fetcher/index.js"; * A page of results from a paginated API. * * @template T The type of the items in the page. + * @template R The type of the response object. */ -export class Page implements AsyncIterable { +export class Page implements AsyncIterable { public data: T[]; public rawResponse: RawResponse; + public response: R; - private response: unknown; - private _hasNextPage: (response: unknown) => boolean; - private getItems: (response: unknown) => T[]; - private loadNextPage: (response: unknown) => HttpResponsePromise; + private _hasNextPage: (response: R) => boolean; + private getItems: (response: R) => T[]; + private loadNextPage: (response: R) => HttpResponsePromise; constructor({ response, @@ -21,11 +22,11 @@ export class Page implements AsyncIterable { getItems, loadPage, }: { - response: unknown; + response: R; rawResponse: RawResponse; - hasNextPage: (response: unknown) => boolean; - getItems: (response: unknown) => T[]; - loadPage: (response: unknown) => HttpResponsePromise; + hasNextPage: (response: R) => boolean; + getItems: (response: R) => T[]; + loadPage: (response: R) => HttpResponsePromise; }) { this.response = response; this.rawResponse = rawResponse; diff --git a/seed/ts-sdk/pagination/src/core/pagination/Pageable.ts b/seed/ts-sdk/pagination/src/core/pagination/Pageable.ts index 5689e1e35025..458162f5edfb 100644 --- a/seed/ts-sdk/pagination/src/core/pagination/Pageable.ts +++ b/seed/ts-sdk/pagination/src/core/pagination/Pageable.ts @@ -11,8 +11,4 @@ export declare namespace Pageable { } } -export class Pageable extends Page { - constructor(args: Pageable.Args) { - super(args as any); - } -} +export class Pageable extends Page {}