Skip to content

Commit dc81552

Browse files
ruyadornoDesplandis
authored andcommitted
🤖 Merge PR DefinitelyTyped#65527 Add stream factory method type in pg by @ruyadorno
Refs: brianc/node-postgres#2898
1 parent f2cf05b commit dc81552

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

types/pg/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface ClientConfig {
2121
host?: string | undefined;
2222
connectionString?: string | undefined;
2323
keepAlive?: boolean | undefined;
24-
stream?: stream.Duplex | undefined;
24+
stream?: () => stream.Duplex | stream.Duplex | undefined;
2525
statement_timeout?: false | number | undefined;
2626
ssl?: boolean | ConnectionOptions | undefined;
2727
query_timeout?: number | undefined;

types/pg/pg-tests.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { connect } from 'net';
12
import { types, Client, CustomTypesConfig, QueryArrayConfig, Pool, DatabaseError } from 'pg';
23
import TypeOverrides = require('pg/lib/type-overrides');
34
import { NoticeMessage } from 'pg-protocol/dist/messages';
@@ -326,6 +327,14 @@ c = new Client({
326327
connectionTimeoutMillis: 1000, // connection timeout optionally specified
327328
});
328329

330+
// using custom socket factory method
331+
c = new Client({
332+
stream: () => connect({
333+
host: 'my.database-server.com',
334+
port: 5334,
335+
}),
336+
});
337+
329338
const dynamicPasswordSync = new Client({
330339
password: () => 'sync-secret',
331340
});

0 commit comments

Comments
 (0)