Skip to content

Commit 440517e

Browse files
authored
fix(NODE-3624): Incorrect default aggregation generic type (#2987)
1 parent a8e9938 commit 440517e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/collection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ export class Collection<TSchema extends Document = Document> {
13661366
* @param pipeline - An array of aggregation pipelines to execute
13671367
* @param options - Optional settings for the command
13681368
*/
1369-
aggregate<T = TSchema>(
1369+
aggregate<T = Document>(
13701370
pipeline: Document[] = [],
13711371
options?: AggregateOptions
13721372
): AggregationCursor<T> {

test/types/community/collection/aggregate.test-d.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expectType } from 'tsd';
2-
import { AggregationCursor, MongoClient } from '../../../../src/index';
1+
import { expectNotType, expectType } from 'tsd';
2+
import { AggregationCursor, MongoClient, Document } from '../../../../src/index';
33

44
// collection.aggregate tests
55
const client = new MongoClient('');
@@ -11,6 +11,10 @@ interface Payment {
1111
}
1212
const cursor: AggregationCursor<Payment> = collection.aggregate<Payment>([{}]);
1313

14+
const payments = db.collection<Payment>('banking');
15+
expectType<AggregationCursor<Document>>(payments.aggregate());
16+
expectNotType<AggregationCursor<Payment>>(payments.aggregate());
17+
1418
cursor.match({ bar: 1 }).limit(10);
1519

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

0 commit comments

Comments
 (0)