diff --git a/pg/pg-tests.ts b/pg/pg-tests.ts index 087c60834..99d1fac9b 100644 --- a/pg/pg-tests.ts +++ b/pg/pg-tests.ts @@ -12,10 +12,13 @@ pg.connect(conString, (err, client, done) => { return console.error("Error fetching client from pool", err); } client.query("SELECT $1::int AS number", ["1"], (err, result) => { - done(); if (err) { + done(err); return console.error("Error running query", err); } + else { + done(); + } console.log(result.rows[0]["number"]); return null; }); @@ -37,4 +40,4 @@ client.connect((err) => { return null; }); return null; -}); \ No newline at end of file +}); diff --git a/pg/pg.d.ts b/pg/pg.d.ts index 88b3debe4..64a92d96b 100644 --- a/pg/pg.d.ts +++ b/pg/pg.d.ts @@ -9,8 +9,8 @@ declare module "pg" { import events = require("events"); import stream = require("stream"); - export function connect(connection: string, callback: (err: Error, client: Client, done: () => void) => void): void; - export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: () => void) => void): void; + export function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; + export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; export function end(): void; export interface ConnectionConfig {