diff --git a/src/sessions.ts b/src/sessions.ts index 1f8df23490..b4b59f232c 100644 --- a/src/sessions.ts +++ b/src/sessions.ts @@ -453,7 +453,7 @@ export class ClientSession extends TypedEventEmitter { async withTransaction( fn: WithTransactionCallback, options?: TransactionOptions - ): Promise { + ): Promise { const startTime = now(); return attemptTransaction(this, startTime, fn, options); } diff --git a/test/types/community/transaction.test-d.ts b/test/types/community/transaction.test-d.ts index 50cd9133b3..949d5a17f6 100644 --- a/test/types/community/transaction.test-d.ts +++ b/test/types/community/transaction.test-d.ts @@ -1,4 +1,6 @@ -import { type ClientSession, MongoClient, ReadConcern } from '../../mongodb'; +import { expectType } from 'tsd'; + +import { type ClientSession, type InsertOneResult, MongoClient, ReadConcern } from '../../mongodb'; // TODO(NODE-3345): Improve these tests to use expect assertions more @@ -111,11 +113,7 @@ try { client.withSession(session => runTransactionWithRetry(updateEmployeeInfo, client, session)); const col = client.db('test').collection<{ _id: string }>('col'); -const ok = await session.withTransaction(async () => { +const insertResult = await session.withTransaction(async () => { return await col.insertOne({ _id: 'one' }, { session }); }); -if (ok) { - console.log('success'); -} else { - console.log('nothing done'); -} +expectType>(insertResult);