[Types] Adjusments to ApplyBasicQueryCasting (ff2bf3e8b3abe0e09a523465e5db8743083702b9) break FilterQueries for generic types #11964
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Prerequisites
Mongoose version
6.4.0
Node.js version
16.x
MongoDB server version
5.x
Description
The changes from ff2bf3e break
FilterQuery
s for generic types that have some know properties. With this change, it's not possible anymore to assign values for the known properties.It seems like the issue is the
T[0] &
inWhat exactly is the purpose of having
T[0] & defaultT
? For arrays, that would mean the property needs to be of the element type, and the array type or an array of the array type or any non nullable type, at the same time. That doesn't make a lot of sense to me.Also, I doubt
{}
is the correct type here. It means "any non nullable value", not "empty object". In particular, you can do stuff likeconst foo: {} = true
.null
andundefined
are the only values that can not be assigned to it. I doubt that's what's meant here.From what I can see, the second generic parameter (
defaultT
) isn't ever set explicitly, so what is the purpose of it?And lastly, that commit also introduces some tests, but it is in no way clear how the tests are related to the changes. And it seems like they don't cover all parts of the changes. So I think the tests should be expanded a bit here.
Steps to Reproduce
Expected Behavior
Using
FilterQuery
with generic types with know properties works as it has previously.The text was updated successfully, but these errors were encountered: