From a82984442a41b4835ea423646c37a53c7b73ca88 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Mon, 27 Sep 2021 15:36:44 -0400 Subject: [PATCH] fix(NODE-3624): Incorrect default aggregation generic type (#2987) --- src/collection.ts | 2 +- test/types/community/collection/aggregate.test-d.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/collection.ts b/src/collection.ts index fd085026888..3fe20d6b415 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -1366,7 +1366,7 @@ export class Collection { * @param pipeline - An array of aggregation pipelines to execute * @param options - Optional settings for the command */ - aggregate( + aggregate( pipeline: Document[] = [], options?: AggregateOptions ): AggregationCursor { diff --git a/test/types/community/collection/aggregate.test-d.ts b/test/types/community/collection/aggregate.test-d.ts index 2dea5b0839d..66dffde960a 100644 --- a/test/types/community/collection/aggregate.test-d.ts +++ b/test/types/community/collection/aggregate.test-d.ts @@ -1,5 +1,5 @@ -import { expectType } from 'tsd'; -import { AggregationCursor, MongoClient } from '../../../../src/index'; +import { expectNotType, expectType } from 'tsd'; +import { AggregationCursor, MongoClient, Document } from '../../../../src/index'; // collection.aggregate tests const client = new MongoClient(''); @@ -11,6 +11,10 @@ interface Payment { } const cursor: AggregationCursor = collection.aggregate([{}]); +const payments = db.collection('banking'); +expectType>(payments.aggregate()); +expectNotType>(payments.aggregate()); + cursor.match({ bar: 1 }).limit(10); collection.aggregate([{ $match: { bar: 1 } }, { $limit: 10 }]);