-
Type: Bug
-
Resolution: Fixed
-
Priority: Blocker - P1
-
Affects Version/s: None
-
Component/s: None
What problem are you facing?
With last version including "Type inference for nested documents", findOne (and many other functions) does not accept an interface as a filter if it contains an array.
What driver and relevant dependency versions are you using?
mongodb@4.3.0
Steps to reproduce?
export interface S
{ readonly a: readonly string[] }const obj =
{ a: [''] };
(await ((await getClient()).db('db').collection<S>('col').updateOne(obj as unknown as S, { $set:
})));
=> TypeScript error Argument of type 'S' is not assignable to parameter of type 'Filter<S>'.
Type 'S' is not assignable to type '{ [x: `a.${number}`]: Condition<string> | undefined; _id?: Condition<ObjectId>; }'.
Index signature for type '`a.${number}`' is missing in type 'S'.ts(2345)
(await ((await getClient()).db('db').collection<S>('col').updateOne(obj, { $set:
{ a: [''] } })));
=> No TypeScript error, here obj is an object, not an interface
- depends on
-
NODE-3857 Investigate NODE-3856 - Can not use a TypeScript interface as a filter with embeded array
- Closed