-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Cannot use FilterQuery<Type> when Type
is a class
#14473
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Comments
Hi, I also encountered the issue in 8.3.0, but I don't think it's linked to classes, I have the same with a type: export function setCreatedOnInFilter<Entity extends { createdOn: Date }>(
mongooseFilter: FilterQuery<Entity>,
someDate: Date,
) {
mongooseFilter.createdOn = { $gt: someDate };
} This yields the compile error (typescript strict mode on):
As hinted in this comment, it works in 8.2.2. TBH I'm not sure I understand how TS resolves the type condition to an array. |
Same problem. In version 8.2.3 you broke backward compatibility. |
vkarpov15
added a commit
that referenced
this issue
Apr 10, 2024
types(query): make `FilterQuery` props resolve to `any` for generics support
This was referenced May 21, 2024
This was referenced Jun 7, 2024
This was referenced Jun 9, 2024
This was referenced Jun 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.2.3
Node.js version
20
MongoDB server version
7
Typescript version (if applicable)
^5
Description
When I create a generic function that receive a generic type
D
and D extends fromAbstractSchema
then I could not useFilterQuery<D>
with any typeSteps to Reproduce
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: