@@ -1600,7 +1600,9 @@ export type GetStaticPaths = (
16001600 * const { slug } = Astro.params as Params;
16011601 * ```
16021602 */
1603- export type InferGetStaticParamsType < T > = T extends ( ) => infer R | Promise < infer R >
1603+ export type InferGetStaticParamsType < T > = T extends (
1604+ opts ?: GetStaticPathsOptions
1605+ ) => infer R | Promise < infer R >
16041606 ? R extends Array < infer U >
16051607 ? U extends { params : infer P }
16061608 ? P
@@ -1631,7 +1633,9 @@ export type InferGetStaticParamsType<T> = T extends () => infer R | Promise<infe
16311633 * const { propA, propB } = Astro.props;
16321634 * ```
16331635 */
1634- export type InferGetStaticPropsType < T > = T extends ( ) => infer R | Promise < infer R >
1636+ export type InferGetStaticPropsType < T > = T extends (
1637+ opts : GetStaticPathsOptions
1638+ ) => infer R | Promise < infer R >
16351639 ? R extends Array < infer U >
16361640 ? U extends { props : infer P }
16371641 ? P
@@ -1678,13 +1682,13 @@ export type MarkdownContent<T extends Record<string, any> = Record<string, any>>
16781682 *
16791683 * [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
16801684 */
1681- export interface PaginateOptions {
1685+ export interface PaginateOptions < PaginateProps extends Props , PaginateParams extends Params > {
16821686 /** the number of items per-page (default: `10`) */
16831687 pageSize ?: number ;
16841688 /** key: value object of page params (ex: `{ tag: 'javascript' }`) */
1685- params ?: Params ;
1689+ params ?: PaginateParams ;
16861690 /** object of props to forward to `page` result */
1687- props ?: Props ;
1691+ props ?: PaginateProps ;
16881692}
16891693
16901694/**
@@ -1718,7 +1722,33 @@ export interface Page<T = any> {
17181722 } ;
17191723}
17201724
1721- export type PaginateFunction = ( data : any [ ] , args ?: PaginateOptions ) => GetStaticPathsResult ;
1725+ type OmitIndexSignature < ObjectType > = {
1726+ // eslint-disable-next-line @typescript-eslint/ban-types
1727+ [ KeyType in keyof ObjectType as { } extends Record < KeyType , unknown >
1728+ ? never
1729+ : KeyType ] : ObjectType [ KeyType ] ;
1730+ } ;
1731+ // eslint-disable-next-line @typescript-eslint/ban-types
1732+ type Simplify < T > = { [ KeyType in keyof T ] : T [ KeyType ] } & { } ;
1733+ export type PaginateFunction = <
1734+ PaginateData ,
1735+ AdditionalPaginateProps extends Props ,
1736+ AdditionalPaginateParams extends Params ,
1737+ > (
1738+ data : PaginateData [ ] ,
1739+ args ?: PaginateOptions < AdditionalPaginateProps , AdditionalPaginateParams >
1740+ ) => {
1741+ params : Simplify <
1742+ {
1743+ page : string | undefined ;
1744+ } & OmitIndexSignature < AdditionalPaginateParams >
1745+ > ;
1746+ props : Simplify <
1747+ {
1748+ page : Page < PaginateData > ;
1749+ } & OmitIndexSignature < AdditionalPaginateProps >
1750+ > ;
1751+ } [ ] ;
17221752
17231753export type Params = Record < string , string | undefined > ;
17241754
0 commit comments