-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter query Condition
type might as well be any
#14397
Labels
typescript
Types or Types-test related issue / Pull Request
Comments
@sderrow I think I do have a solution on fixing this, but is there any condition where the |
I did find a few cases where any will be required. In this case, its required to do ObjectId casting:
|
IslandRhythms
added
the
typescript
Types or Types-test related issue / Pull Request
label
Mar 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.2.0
Node.js version
18.18.0
MongoDB server version
7.0
Typescript version (if applicable)
4.5.2
Description
The following appears in query.d.ts:
The
| any
union inApplyBasicQueryCasting<T>
, means thatApplyBasicQueryCasting
isany
, which carries through toCondition<T>
beingany
as well.I think that defeats the purpose of the
Condition
type in the first place, since now there's no support for prompting the user with valid Mongo operators like$regex
and$gte
or displaying type errors if you try to pass an invalid value into such an operator (e.g.,{ $regex: 402 }
or{ $exists: "hello" }
).Steps to Reproduce
Expected Behavior
Additional Typescript support when it comes to writing filter queries. I understand there's a need for
any
, but is it possible to do it without sacrificing the operator help?The text was updated successfully, but these errors were encountered: