Skip to content

Commit 2492dd2

Browse files
authored
fix: enumerate function override call signatures (#2687)
Function overrides now declare each possible form of the call signature, including the actual call signature NODE-2934
1 parent cc4b9e0 commit 2492dd2

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/cmap/connection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ export class Connection extends EventEmitter {
263263
}
264264

265265
destroy(): void;
266-
destroy(callback?: Callback): void;
267-
destroy(options?: DestroyOptions): void;
268-
destroy(options?: DestroyOptions, callback?: Callback): void;
266+
destroy(callback: Callback): void;
267+
destroy(options: DestroyOptions): void;
268+
destroy(options: DestroyOptions, callback: Callback): void;
269269
destroy(options?: DestroyOptions | Callback, callback?: Callback): void {
270270
if (typeof options === 'function') {
271271
callback = options;

src/collection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,6 @@ export class Collection {
12421242
* @param pipeline - An array of {@link https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
12431243
* @param options - Optional settings for the command
12441244
*/
1245-
watch(): ChangeStream;
1246-
watch(pipeline?: Document[]): ChangeStream;
12471245
watch(pipeline?: Document[], options?: ChangeStreamOptions): ChangeStream {
12481246
pipeline = pipeline || [];
12491247
options = options ?? {};

src/cursor/aggregation_cursor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class AggregationCursor extends AbstractCursor {
7777
/** Execute the explain for the cursor */
7878
explain(): Promise<Document>;
7979
explain(callback: Callback): void;
80-
explain(verbosity?: ExplainVerbosityLike): Promise<Document>;
80+
explain(verbosity: ExplainVerbosityLike): Promise<Document>;
8181
explain(
8282
verbosity?: ExplainVerbosityLike | Callback,
8383
callback?: Callback<Document>

src/mongo_client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export class MongoClient extends EventEmitter {
346346
* @see docs.mongodb.org/manual/reference/connection-string/
347347
*/
348348
connect(): Promise<MongoClient>;
349-
connect(callback?: Callback<MongoClient>): void;
349+
connect(callback: Callback<MongoClient>): void;
350350
connect(callback?: Callback<MongoClient>): Promise<MongoClient> | void {
351351
if (callback && typeof callback !== 'function') {
352352
throw new TypeError('`connect` only accepts a callback');
@@ -457,7 +457,11 @@ export class MongoClient extends EventEmitter {
457457
// Create client
458458
const mongoClient = new MongoClient(url, options);
459459
// Execute the connect method
460-
return mongoClient.connect(callback);
460+
if (callback) {
461+
return mongoClient.connect(callback);
462+
} else {
463+
return mongoClient.connect();
464+
}
461465
} catch (error) {
462466
if (callback) return callback(error);
463467
else return PromiseProvider.get().reject(error);

0 commit comments

Comments
 (0)