Skip to content

Commit

Permalink
fix(NODE-3624): Incorrect default aggregation generic type (#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Sep 27, 2021
1 parent a8e9938 commit 440517e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/collection.ts
Expand Up @@ -1366,7 +1366,7 @@ export class Collection<TSchema extends Document = Document> {
* @param pipeline - An array of aggregation pipelines to execute
* @param options - Optional settings for the command
*/
aggregate<T = TSchema>(
aggregate<T = Document>(
pipeline: Document[] = [],
options?: AggregateOptions
): AggregationCursor<T> {
Expand Down
8 changes: 6 additions & 2 deletions 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('');
Expand All @@ -11,6 +11,10 @@ interface Payment {
}
const cursor: AggregationCursor<Payment> = collection.aggregate<Payment>([{}]);

const payments = db.collection<Payment>('banking');
expectType<AggregationCursor<Document>>(payments.aggregate());
expectNotType<AggregationCursor<Payment>>(payments.aggregate());

cursor.match({ bar: 1 }).limit(10);

collection.aggregate([{ $match: { bar: 1 } }, { $limit: 10 }]);
Expand Down

0 comments on commit 440517e

Please sign in to comment.