File tree 2 files changed +6
-8
lines changed
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
453
453
async withTransaction < T = any > (
454
454
fn : WithTransactionCallback < T > ,
455
455
options ?: TransactionOptions
456
- ) : Promise < Document | undefined > {
456
+ ) : Promise < T > {
457
457
const startTime = now ( ) ;
458
458
return attemptTransaction ( this , startTime , fn , options ) ;
459
459
}
Original file line number Diff line number Diff line change 1
- import { type ClientSession , MongoClient , ReadConcern } from '../../mongodb' ;
1
+ import { expectType } from 'tsd' ;
2
+
3
+ import { type ClientSession , type InsertOneResult , MongoClient , ReadConcern } from '../../mongodb' ;
2
4
3
5
// TODO(NODE-3345): Improve these tests to use expect assertions more
4
6
@@ -111,11 +113,7 @@ try {
111
113
client . withSession ( session => runTransactionWithRetry ( updateEmployeeInfo , client , session ) ) ;
112
114
113
115
const col = client . db ( 'test' ) . collection < { _id : string } > ( 'col' ) ;
114
- const ok = await session . withTransaction ( async ( ) => {
116
+ const insertResult = await session . withTransaction ( async ( ) => {
115
117
return await col . insertOne ( { _id : 'one' } , { session } ) ;
116
118
} ) ;
117
- if ( ok ) {
118
- console . log ( 'success' ) ;
119
- } else {
120
- console . log ( 'nothing done' ) ;
121
- }
119
+ expectType < InsertOneResult < { _id : string } > > ( insertResult ) ;
You can’t perform that action at this time.
0 commit comments