also looking at this
fix(client): keep client.d.ts free of `any`, and make the guard that says so run
#1132
3 files
+62
-8
| @@ -640,8 +640,14 @@ export interface PaginateOptions { | ||
| 640 | 640 | perPage?: number |
| 641 | 641 | /** 1-based page number. Defaults to 1. */ |
| 642 | 642 | 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 } | |
| 645 | 651 | } |
| 646 | 652 | |
| 647 | 653 | export type QueryResult = unknown |
| @@ -5854,7 +5860,7 @@ export function createQueryBuilder<DB extends AnyDatabaseSchema>(state?: Partial | ||
| 5854 | 5860 | if (typeof perPage === 'object' && perPage !== null) { |
| 5855 | 5861 | const options = perPage |
| 5856 | 5862 | 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 } } : {} | |
| 5858 | 5864 | perPage = options.perPage ?? 10 |
| 5859 | 5865 | } |
| 5860 | 5866 | if (!Number.isFinite(perPage) || perPage <= 0 || !Number.isInteger(perPage)) |