ReviewOS

also looking at this

stacks/bun-query-builder

fix(client): keep client.d.ts free of `any`, and make the guard that says so run

#1132
Merged glennmichael123 wants to merge fix/paginate-options-any into main
3 files +62 -8
packages/bun-query-builder/src/client.tsmodified+9-3
Changes to packages/bun-query-builder/src/client.ts
@@ -640,8 +640,14 @@ export interface PaginateOptions {
640640 perPage?: number
641641 /** 1-based page number. Defaults to 1. */
642642 page?: number
643 /** Run the count and the page query inside this transaction — see #1051. */
644 tx?: { unsafe: (sql: string, params?: any[]) => any }
643 /**
644 * Run the count and the page query inside this transaction — see #1051.
645 *
646 * `unknown` rather than `any`, matching the positional overload's declared
647 * `opts.tx`. An `any` here is published in `client.d.ts`, which is the type
648 * an app touches on every query — #1117 took that file to zero and pinned it.
649 */
650 tx?: { unsafe: (sql: string, params?: unknown[]) => unknown }
645651}
646652
647653export type QueryResult = unknown
@@ -5854,7 +5860,7 @@ export function createQueryBuilder<DB extends AnyDatabaseSchema>(state?: Partial
58545860 if (typeof perPage === 'object' && perPage !== null) {
58555861 const options = perPage
58565862 page = options.page ?? 1
5857 opts = options.tx ? { tx: options.tx } : {}
5863 opts = options.tx ? { tx: options.tx as { unsafe: (sql: string, params?: any[]) => any } } : {}
58585864 perPage = options.perPage ?? 10
58595865 }
58605866 if (!Number.isFinite(perPage) || perPage <= 0 || !Number.isInteger(perPage))