-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
NODE-4494 Description
What problem are you facing?
`Filter` and `UpdateFilter` do not infer the correct type of `Record` values.
What driver and relevant dependency versions are you using?
- mongodb v4.8.1
- typescript v4.7.4
Steps to reproduce?
import { Filter, PropertyType, UpdateFilter } from 'mongodb'; interface Foo { data: Record<string, boolean>; } const queryOK: Filter<Foo> = { "data.path": true }; // ^ OK const queryFail: Filter<Foo> = { "data.path": 1 }; // ^ Fail - TS does not flag the wrong type of `data.path` const updateOK: UpdateFilter<Foo> = { $set: { "data.path": true } }; // ^ OK - Expected const updateFail: UpdateFilter<Foo> = { $set: { "data.path": 1 } }; // ^ Fail - TS does not flag the wrong type of `data.path` type DataValueType = PropertyType<Foo, `data.${string}`>; // ^ `unknown` - should be `boolean`
- is depended on by
-
NODE-4494 Filter / UpdateFilter do not infer the correct type of Record values
- Backlog