From cd603e8c78f24422dcad4c65e9ca22eed94aa55e Mon Sep 17 00:00:00 2001 From: Eric Adum Date: Fri, 3 Sep 2021 10:32:57 -0400 Subject: [PATCH] fix(NODE-3467): allow object type for aggregate out helper (#2971) --- 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));