@@ -41,9 +41,7 @@ export class MongoClient {
41
41
*
42
42
* @param options Connection options or a MongoDB URI
43
43
*/
44
- async connect (
45
- options : ConnectOptions | string ,
46
- ) : Promise < Database > {
44
+ async connect ( options : ConnectOptions | string ) : Promise < Database > {
47
45
try {
48
46
const parsedOptions = typeof options === "string"
49
47
? await parse ( options )
@@ -59,8 +57,10 @@ export class MongoClient {
59
57
this . #buildInfo = await this . runCommand ( this . #defaultDbName, {
60
58
buildInfo : 1 ,
61
59
} ) ;
62
- } catch ( e ) {
63
- throw new MongoDriverError ( `Connection failed: ${ e . message || e } ` ) ;
60
+ } catch ( e : unknown ) {
61
+ throw new MongoDriverError (
62
+ `Connection failed: ${ e instanceof Error ? e . message : "unknown" } ` ,
63
+ ) ;
64
64
}
65
65
return this . database ( ( options as ConnectOptions ) . db ) ;
66
66
}
@@ -71,12 +71,14 @@ export class MongoClient {
71
71
* @param options Options to pass to the `listDatabases` command
72
72
* @returns A list of databases including their name, size on disk, and whether they are empty
73
73
*/
74
- async listDatabases ( options : {
75
- filter ?: Document ;
76
- nameOnly ?: boolean ;
77
- authorizedCollections ?: boolean ;
78
- comment ?: Document ;
79
- } = { } ) : Promise < ListDatabaseInfo [ ] > {
74
+ async listDatabases (
75
+ options : {
76
+ filter ?: Document ;
77
+ nameOnly ?: boolean ;
78
+ authorizedCollections ?: boolean ;
79
+ comment ?: Document ;
80
+ } = { } ,
81
+ ) : Promise < ListDatabaseInfo [ ] > {
80
82
const { databases } = await this . getCluster ( ) . protocol . commandSingle (
81
83
"admin" ,
82
84
{
0 commit comments