From 0815f05d15668b3f4eaedb3a2c443966ac1aaa27 Mon Sep 17 00:00:00 2001 From: Brian Carlson Date: Fri, 18 Jul 2025 11:22:04 -0500 Subject: [PATCH] Slightly better types --- packages/pg-transaction/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/pg-transaction/src/index.ts b/packages/pg-transaction/src/index.ts index 46430207..37eda913 100644 --- a/packages/pg-transaction/src/index.ts +++ b/packages/pg-transaction/src/index.ts @@ -8,7 +8,10 @@ function isPool(clientOrPool: Client | Pool): clientOrPool is Pool { return 'idleCount' in clientOrPool } -async function transaction(clientOrPool: Client | Pool, cb: (client: Client) => Promise): Promise { +async function transaction( + clientOrPool: Client | Pool, + cb: (client: Client | PoolClient) => Promise +): Promise { let client: Client | PoolClient if (isPool(clientOrPool)) { // It's a Pool @@ -19,7 +22,7 @@ async function transaction(clientOrPool: Client | Pool, cb: (client: Client) } await client.query('BEGIN') try { - const result = await cb(client as Client) + const result = await cb(client) await client.query('COMMIT') return result } catch (error) {