From 07fcb1bd3da33dadd03a4757fc37d2d9c278b1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Mon, 23 Dec 2019 17:02:41 +0100 Subject: [PATCH] feat(pg): rework constructor documentation. Closes #41167 (#41174) - remove outdated comment - add link to the documentation - update test with parameterless ctor Thanks! --- types/pg/index.d.ts | 11 ++++++++--- types/pg/pg-tests.ts | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index 82654afd04..255165a1df 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -144,10 +144,15 @@ export class Connection extends events.EventEmitter { end(): void; } +/** + * {@link https://node-postgres.com/api/pool} + */ export class Pool extends events.EventEmitter { - // `new Pool('pg://user@localhost/mydb')` is not allowed. - // But it passes type check because of issue: - // https://github.com/Microsoft/TypeScript/issues/7485 + /** + * Every field of the config object is entirely optional. + * The config passed to the pool is also passed to every client + * instance within the pool when the pool creates that client. + */ constructor(config?: PoolConfig); readonly totalCount: number; diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index c464f2f487..673f4105e4 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -124,6 +124,12 @@ client.end() .then(() => console.log('client has disconnected')) .catch(err => console.error('error during disconnection', err.stack)); +// pg.Pool +// https://node-postgres.com/api/pool + +// no params ctor +const poolParameterlessCtor = new Pool(); + const poolOne = new Pool({ connectionString: 'postgresql://dbuser:secretpassword@database.server.com:3211/mydb' });