Skip to content

fix: enumerate function override call signatures #2687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ export class Connection extends EventEmitter {
}

destroy(): void;
destroy(callback?: Callback): void;
destroy(options?: DestroyOptions): void;
destroy(options?: DestroyOptions, callback?: Callback): void;
destroy(callback: Callback): void;
destroy(options: DestroyOptions): void;
destroy(options: DestroyOptions, callback: Callback): void;
destroy(options?: DestroyOptions | Callback, callback?: Callback): void {
if (typeof options === 'function') {
callback = options;
Expand Down
2 changes: 0 additions & 2 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,6 @@ export class Collection {
* @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.
* @param options - Optional settings for the command
*/
watch(): ChangeStream;
watch(pipeline?: Document[]): ChangeStream;
watch(pipeline?: Document[], options?: ChangeStreamOptions): ChangeStream {
pipeline = pipeline || [];
options = options ?? {};
Expand Down
2 changes: 1 addition & 1 deletion src/cursor/aggregation_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class AggregationCursor extends AbstractCursor {
/** Execute the explain for the cursor */
explain(): Promise<Document>;
explain(callback: Callback): void;
explain(verbosity?: ExplainVerbosityLike): Promise<Document>;
explain(verbosity: ExplainVerbosityLike): Promise<Document>;
explain(
verbosity?: ExplainVerbosityLike | Callback,
callback?: Callback<Document>
Expand Down
8 changes: 6 additions & 2 deletions src/mongo_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class MongoClient extends EventEmitter {
* @see docs.mongodb.org/manual/reference/connection-string/
*/
connect(): Promise<MongoClient>;
connect(callback?: Callback<MongoClient>): void;
connect(callback: Callback<MongoClient>): void;
connect(callback?: Callback<MongoClient>): Promise<MongoClient> | void {
if (callback && typeof callback !== 'function') {
throw new TypeError('`connect` only accepts a callback');
Expand Down Expand Up @@ -457,7 +457,11 @@ export class MongoClient extends EventEmitter {
// Create client
const mongoClient = new MongoClient(url, options);
// Execute the connect method
return mongoClient.connect(callback);
if (callback) {
return mongoClient.connect(callback);
} else {
return mongoClient.connect();
}
} catch (error) {
if (callback) return callback(error);
else return PromiseProvider.get().reject(error);
Expand Down