Skip to content

feat(types): improve paginate type inference and safety#59

Open
tris203 wants to merge 1 commit into
covenanttechnologysolutions:masterfrom
tris203:review/paginate-type-inference
Open

feat(types): improve paginate type inference and safety#59
tris203 wants to merge 1 commit into
covenanttechnologysolutions:masterfrom
tris203:review/paginate-type-inference

Conversation

@tris203

@tris203 tris203 commented May 29, 2026

Copy link
Copy Markdown

Changes

  • Updates Automate.paginate and Manage.paginate to preserve the API method’s argument and return types.
  • Replaces the broad Function-based PaginationApiMethod type with a generic function signature.
  • Updates pagination internals so makePaginate and getPage return typed arrays instead of unknown[].
  • Adds a type test verifying:
  • paginate returns Promise<T[]> based on the API method result type.
  • invalid method arguments are rejected by TypeScript.
  • Adjusts the test tsconfig rootDir so the new type test can reference source files correctly.

Why

Previously, paginate erased method-specific types, returning Promise<unknown[]> and accepting loosely typed arguments. This made pagination harder to use safely and weakened editor/type-checking support.
This change keeps pagination behavior the same at runtime while making TypeScript catch invalid usage earlier.

Refactor the paginate method in Automate and Manage to use generic types,
preserving the argument and return types of the API method passed in.
Update PaginationApiMethod and related helpers for better type inference.
Add a type test to ensure correct usage and argument validation. Adjust
test tsconfig rootDir for proper type checking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant