From 6dab065ca8743619aa0250d148a0704a00cf7100 Mon Sep 17 00:00:00 2001 From: emadum Date: Thu, 2 Sep 2021 09:47:17 -0400 Subject: [PATCH] fix(NODE-3467): allow object type for aggregate out helper --- src/cursor/aggregation_cursor.ts | 2 +- test/types/mongodb.test-d.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cursor/aggregation_cursor.ts b/src/cursor/aggregation_cursor.ts index 6efae2035c..ffe658e34e 100644 --- a/src/cursor/aggregation_cursor.ts +++ b/src/cursor/aggregation_cursor.ts @@ -121,7 +121,7 @@ export class AggregationCursor extends AbstractCursor(await composedMap.next()); expectType(await composedMap.toArray()); const builtCursor = coll.aggregate(); -expectType>(builtCursor.out('string')); // should allow string values for the out helper -expectError(builtCursor.out(1)); // should error on non-string values +// should allow string values for the out helper +expectType>(builtCursor.out('collection')); +// should also allow an object specifying db/coll (as of MongoDB 4.4) +expectType>(builtCursor.out({ db: 'db', coll: 'collection' })); +// should error on other object shapes +expectError(builtCursor.out({ other: 'shape' })); +// should error on non-object, non-string values +expectError(builtCursor.out(1));