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) {