@@ -62,7 +62,7 @@ import type { ClientMetadata } from './handshake/client_metadata';
62
62
import { StreamDescription , type StreamDescriptionOptions } from './stream_description' ;
63
63
import { type CompressorName , decompressResponse } from './wire_protocol/compression' ;
64
64
import { onData } from './wire_protocol/on_data' ;
65
- import { MongoDBResponse } from './wire_protocol/responses' ;
65
+ import { MongoDBResponse , type MongoDBResponseConstructor } from './wire_protocol/responses' ;
66
66
import { getReadPreference , isSharded } from './wire_protocol/shared' ;
67
67
68
68
/** @internal */
@@ -416,7 +416,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
416
416
private async * sendWire (
417
417
message : WriteProtocolMessageType ,
418
418
options : CommandOptions ,
419
- responseType ?: typeof MongoDBResponse
419
+ responseType ?: MongoDBResponseConstructor
420
420
) : AsyncGenerator < MongoDBResponse > {
421
421
this . throwIfAborted ( ) ;
422
422
@@ -462,8 +462,8 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
462
462
private async * sendCommand (
463
463
ns : MongoDBNamespace ,
464
464
command : Document ,
465
- options : CommandOptions = { } ,
466
- responseType ?: typeof MongoDBResponse
465
+ options : CommandOptions ,
466
+ responseType ?: MongoDBResponseConstructor
467
467
) {
468
468
const message = this . prepareCommand ( ns . db , command , options ) ;
469
469
@@ -574,32 +574,24 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
574
574
}
575
575
}
576
576
577
- public async command < T extends typeof MongoDBResponse > (
577
+ public async command < T extends MongoDBResponseConstructor > (
578
578
ns : MongoDBNamespace ,
579
579
command : Document ,
580
580
options : CommandOptions | undefined ,
581
581
responseType : T | undefined
582
- ) : Promise < T extends undefined ? Document : InstanceType < T > > ;
583
-
584
- public async command (
585
- ns : MongoDBNamespace ,
586
- command : Document ,
587
- options ?: undefined
588
- ) : Promise < Document > ;
582
+ ) : Promise < typeof responseType extends undefined ? Document : InstanceType < T > > ;
589
583
590
584
public async command (
591
585
ns : MongoDBNamespace ,
592
586
command : Document ,
593
- options : CommandOptions
587
+ options ? : CommandOptions
594
588
) : Promise < Document > ;
595
589
596
- public async command ( ns : MongoDBNamespace , command : Document ) : Promise < Document > ;
597
-
598
590
public async command (
599
591
ns : MongoDBNamespace ,
600
592
command : Document ,
601
593
options : CommandOptions = { } ,
602
- responseType ?: typeof MongoDBResponse
594
+ responseType ?: MongoDBResponseConstructor
603
595
) : Promise < Document > {
604
596
this . throwIfAborted ( ) ;
605
597
for await ( const document of this . sendCommand ( ns , command , options , responseType ) ) {
@@ -728,7 +720,7 @@ export class CryptoConnection extends Connection {
728
720
this . autoEncrypter = options . autoEncrypter ;
729
721
}
730
722
731
- public override async command < T extends typeof MongoDBResponse > (
723
+ public override async command < T extends MongoDBResponseConstructor > (
732
724
ns : MongoDBNamespace ,
733
725
command : Document ,
734
726
options : CommandOptions | undefined ,
@@ -741,9 +733,7 @@ export class CryptoConnection extends Connection {
741
733
options ?: CommandOptions
742
734
) : Promise < Document > ;
743
735
744
- public override async command ( ns : MongoDBNamespace , command : Document ) : Promise < Document > ;
745
-
746
- override async command < T extends typeof MongoDBResponse > (
736
+ override async command < T extends MongoDBResponseConstructor > (
747
737
ns : MongoDBNamespace ,
748
738
cmd : Document ,
749
739
options ?: CommandOptions ,
0 commit comments