Skip to content

Commit 0815f05

Browse files
author
Brian Carlson
committed
Slightly better types
1 parent 64a9aa2 commit 0815f05

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/pg-transaction/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ function isPool(clientOrPool: Client | Pool): clientOrPool is Pool {
88
return 'idleCount' in clientOrPool
99
}
1010

11-
async function transaction<T>(clientOrPool: Client | Pool, cb: (client: Client) => Promise<T>): Promise<T> {
11+
async function transaction<T>(
12+
clientOrPool: Client | Pool,
13+
cb: (client: Client | PoolClient) => Promise<T>
14+
): Promise<T> {
1215
let client: Client | PoolClient
1316
if (isPool(clientOrPool)) {
1417
// It's a Pool
@@ -19,7 +22,7 @@ async function transaction<T>(clientOrPool: Client | Pool, cb: (client: Client)
1922
}
2023
await client.query('BEGIN')
2124
try {
22-
const result = await cb(client as Client)
25+
const result = await cb(client)
2326
await client.query('COMMIT')
2427
return result
2528
} catch (error) {

0 commit comments

Comments
 (0)