Skip to content

Commit 63b8e26

Browse files
committed
fix(types): correct return type for Connection.prototype.transaction
Fix #9919 Re: mongodb/node-mongodb-native#3203
1 parent b56cd4a commit 63b8e26

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

test/types/connection.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ expectType<mongodb.Db>(conn.db);
5858
expectType<mongodb.MongoClient>(conn.getClient());
5959
expectType<Connection>(conn.setClient(new mongodb.MongoClient('mongodb://localhost:27017/test')));
6060

61-
expectType<Promise<string>>(conn.transaction<string>(async(res) => {
61+
expectType<Promise<void>>(conn.transaction(async(res) => {
6262
expectType<mongodb.ClientSession>(res);
6363
return 'a';
6464
}));

types/connection.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ declare module 'mongoose' {
197197
* async function executes successfully and attempt to retry if
198198
* there was a retryable error.
199199
*/
200-
transaction<U = any>(fn: (session: mongodb.ClientSession) => Promise<U>): Promise<U>;
200+
transaction(fn: (session: mongodb.ClientSession) => Promise<any>): Promise<void>;
201201

202202
/** Switches to a different database using the same connection pool. */
203203
useDb(name: string, options?: { useCache?: boolean, noListener?: boolean }): Connection;

0 commit comments

Comments
 (0)