Skip to content

Commit

Permalink
Fix:changes the paginate function to allow readonly array types (#13213)
Browse files Browse the repository at this point in the history
* changes the paginate function to allow readonly array types

* Update paginate function to accept readonly arrays

---------

Co-authored-by: Matt Kane <[email protected]>
  • Loading branch information
joshmkennedy and ascorbic authored Feb 12, 2025
1 parent 8e5b89c commit 6bac644
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-crabs-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Allows readonly arrays to be passed to the `paginate()` function
2 changes: 1 addition & 1 deletion packages/astro/src/core/render/paginate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function generatePaginateFunction(
base: AstroConfig['base'],
): (...args: Parameters<PaginateFunction>) => ReturnType<PaginateFunction> {
return function paginateUtility(
data: any[],
data: readonly any[],
args: PaginateOptions<Props, Params> = {},
): ReturnType<PaginateFunction> {
let { pageSize: _pageSize, params: _params, props: _props } = args;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/types/public/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export type PaginateFunction = <
AdditionalPaginateProps extends Props,
AdditionalPaginateParams extends Params,
>(
data: PaginateData[],
data: readonly PaginateData[],
args?: PaginateOptions<AdditionalPaginateProps, AdditionalPaginateParams>,
) => {
params: Simplify<
Expand Down

0 comments on commit 6bac644

Please sign in to comment.