File tree 2 files changed +9
-1
lines changed
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -496,7 +496,7 @@ export type NestedPaths<Type> = Type extends
496
496
| { _bsontype : string }
497
497
? [ ]
498
498
: Type extends ReadonlyArray < infer ArrayType >
499
- ? [ number , ...NestedPaths < ArrayType > ]
499
+ ? [ ] | [ number , ...NestedPaths < ArrayType > ]
500
500
: Type extends Map < string , any >
501
501
? [ string ]
502
502
: // eslint-disable-next-line @typescript-eslint/ban-types
Original file line number Diff line number Diff line change @@ -204,6 +204,14 @@ expectNotType<Filter<PetModel>>({ 'playmates.0.name': 123 });
204
204
expectNotType < Filter < PetModel > > ( { 'laps.foo' : 'string' } ) ;
205
205
expectNotType < Filter < PetModel > > ( { 'treats.0' : 123 } ) ;
206
206
207
+ /// it should not accept wrong types for nested document array fields
208
+ expectError < Filter < PetModel > > ( {
209
+ treats : {
210
+ $elemMatch : true
211
+ }
212
+ } ) ;
213
+ expectError < Filter < PetModel > > ( { treats : 123 } ) ;
214
+
207
215
// Nested arrays aren't checked
208
216
expectNotType < Filter < PetModel > > ( { 'meta.deep.nestedArray.0' : 'not a number' } ) ;
209
217
You can’t perform that action at this time.
0 commit comments