@@ -5,7 +5,7 @@ import { Readable, Writable } from 'node:stream'
5
5
* @param options Connection options - default to the same as psql
6
6
* @returns An utility function to make queries to the server
7
7
*/
8
- declare function postgres < T extends PostgresTypeList > ( options ?: postgres . Options < T > | undefined ) : postgres . Sql < PostgresTypeList extends T ? { } : { [ type in keyof T ] : T [ type ] extends {
8
+ declare function postgres < T extends Record < string , postgres . PostgresType > = { } > ( options ?: postgres . Options < T > | undefined ) : postgres . Sql < Record < string , postgres . PostgresType > extends T ? { } : { [ type in keyof T ] : T [ type ] extends {
9
9
serialize : ( value : infer R ) => any ,
10
10
parse : ( raw : any ) => infer R
11
11
} ? R : never } >
@@ -15,15 +15,15 @@ declare function postgres<T extends PostgresTypeList>(options?: postgres.Options
15
15
* @param options Connection options - default to the same as psql
16
16
* @returns An utility function to make queries to the server
17
17
*/
18
- declare function postgres < T extends PostgresTypeList > ( url : string , options ?: postgres . Options < T > | undefined ) : postgres . Sql < PostgresTypeList extends T ? { } : { [ type in keyof T ] : T [ type ] extends {
18
+ declare function postgres < T extends Record < string , postgres . PostgresType > = { } > ( url : string , options ?: postgres . Options < T > | undefined ) : postgres . Sql < Record < string , postgres . PostgresType > extends T ? { } : { [ type in keyof T ] : T [ type ] extends {
19
19
serialize : ( value : infer R ) => any ,
20
20
parse : ( raw : any ) => infer R
21
21
} ? R : never } >
22
22
23
23
/**
24
24
* Connection options of Postgres.
25
25
*/
26
- interface BaseOptions < T extends PostgresTypeList > {
26
+ interface BaseOptions < T extends Record < string , postgres . PostgresType > > {
27
27
/** Postgres ip address[s] or domain name[s] */
28
28
host : string | string [ ] | undefined ;
29
29
/** Postgres server[s] port[s] */
@@ -124,13 +124,6 @@ interface BaseOptions<T extends PostgresTypeList> {
124
124
keep_alive : number | null ;
125
125
}
126
126
127
- interface PostgresTypeList {
128
- [ name : string ] : postgres . PostgresType ;
129
- }
130
-
131
- interface JSToPostgresTypeMap {
132
- [ name : string ] : unknown ;
133
- }
134
127
135
128
declare const PRIVATE : unique symbol ;
136
129
@@ -332,7 +325,7 @@ declare namespace postgres {
332
325
[ name : string ] : string ;
333
326
}
334
327
335
- interface Options < T extends PostgresTypeList > extends Partial < BaseOptions < T > > {
328
+ interface Options < T extends Record < string , postgres . PostgresType > > extends Partial < BaseOptions < T > > {
336
329
/** @inheritdoc */
337
330
host ?: string | undefined ;
338
331
/** @inheritdoc */
@@ -364,7 +357,7 @@ declare namespace postgres {
364
357
timeout ?: Options < T > [ 'idle_timeout' ] | undefined ;
365
358
}
366
359
367
- interface ParsedOptions < T extends JSToPostgresTypeMap > extends BaseOptions < { [ name in keyof T ] : PostgresType < T [ name ] > } > {
360
+ interface ParsedOptions < T extends Record < string , unknown > = { } > extends BaseOptions < { [ name in keyof T ] : PostgresType < T [ name ] > } > {
368
361
/** @inheritdoc */
369
362
host : string [ ] ;
370
363
/** @inheritdoc */
@@ -531,7 +524,7 @@ declare namespace postgres {
531
524
| boolean
532
525
| Date // serialized as `string`
533
526
| readonly JSONValue [ ]
534
- | { toJSON ( ) : any } // `toJSON` called by `JSON.stringify`; not typing the return type, typings is strict enough anyway
527
+ | { toJSON ( ) : any } // `toJSON` called by `JSON.stringify`; not typing the return type, types definition is strict enough anyway
535
528
| {
536
529
readonly [ prop : string | number ] :
537
530
| undefined
@@ -637,14 +630,14 @@ declare namespace postgres {
637
630
type Fragment = PendingQuery < any >
638
631
639
632
type ParameterOrJSON < T > =
640
- | SerializableParameter < T >
641
- | JSONValue
633
+ | SerializableParameter < T >
634
+ | JSONValue
642
635
643
636
type ParameterOrFragment < T > =
644
- | SerializableParameter < T >
645
- | Fragment
637
+ | SerializableParameter < T >
638
+ | Fragment
646
639
647
- interface Sql < TTypes extends JSToPostgresTypeMap > {
640
+ interface Sql < TTypes extends Record < string , unknown > = { } > {
648
641
/**
649
642
* Query helper
650
643
* @param first Define how the helper behave
@@ -699,7 +692,7 @@ declare namespace postgres {
699
692
prepare ?: boolean | undefined ;
700
693
}
701
694
702
- interface TransactionSql < TTypes extends JSToPostgresTypeMap > extends Sql < TTypes > {
695
+ interface TransactionSql < TTypes extends Record < string , unknown > = { } > extends Sql < TTypes > {
703
696
savepoint < T > ( cb : ( sql : TransactionSql < TTypes > ) => T | Promise < T > ) : Promise < UnwrapPromiseArray < T > > ;
704
697
savepoint < T > ( name : string , cb : ( sql : TransactionSql < TTypes > ) => T | Promise < T > ) : Promise < UnwrapPromiseArray < T > > ;
705
698
}
0 commit comments