ReviewOS

also looking at this

stacks/bun-query-builder

refactor(types): stop publishing `any` across the query builder's surface

#1117
Merged chris wants to merge types/remove-any-from-public-surface into main
13 files +359 -110
packages/bun-query-builder/src/browser.tsmodified+17-6
Changes to packages/bun-query-builder/src/browser.ts
@@ -372,7 +372,9 @@ export class BrowserQueryBuilder<T = any> {
372372 /**
373373 * Add a where clause
374374 */
375 where(column: string, operatorOrValue: WhereOperator | any, value?: any): this {
375 where(column: string, value: unknown): this
376 where(column: string, operator: WhereOperator, value: unknown): this
377 where(column: string, operatorOrValue: unknown, value?: unknown): this {
376378 if (value === undefined) {
377379 // where('column', value) shorthand for equality
378380 this.state.wheres.push({
@@ -397,7 +399,9 @@ export class BrowserQueryBuilder<T = any> {
397399 /**
398400 * Add an OR where clause
399401 */
400 orWhere(column: string, operatorOrValue: WhereOperator | any, value?: any): this {
402 orWhere(column: string, value: unknown): this
403 orWhere(column: string, operator: WhereOperator, value: unknown): this
404 orWhere(column: string, operatorOrValue: unknown, value?: unknown): this {
401405 if (value === undefined) {
402406 this.state.wheres.push({
403407 column,
@@ -420,8 +424,15 @@ export class BrowserQueryBuilder<T = any> {
420424 /**
421425 * Add an AND where clause (alias for where)
422426 */
423 andWhere(column: string, operatorOrValue: WhereOperator | any, value?: any): this {
424 return this.where(column, operatorOrValue, value)
427 andWhere(column: string, value: unknown): this
428 andWhere(column: string, operator: WhereOperator, value: unknown): this
429 andWhere(column: string, operatorOrValue: unknown, value?: unknown): this {
430 // Two args means the second is a value; three means it is an operator -
431 // which is exactly what the overloads above declare, so the dispatch is
432 // split here rather than passing an unknown into the operator position.
433 return value === undefined
434 ? this.where(column, operatorOrValue)
435 : this.where(column, operatorOrValue as WhereOperator, value)
425436 }
426437
427438 /**
@@ -441,14 +452,14 @@ export class BrowserQueryBuilder<T = any> {
441452 /**
442453 * Where column is in array
443454 */
444 whereIn(column: string, values: any[]): this {
455 whereIn(column: string, values: readonly unknown[]): this {
445456 return this.where(column, 'in', values)
446457 }
447458
448459 /**
449460 * Where column is not in array
450461 */
451 whereNotIn(column: string, values: any[]): this {
462 whereNotIn(column: string, values: readonly unknown[]): this {
452463 return this.where(column, 'not in', values)
453464 }
454465