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
Definition of type UpdateQuery
is not very accurate cause code hint not work
#13630
Closed
2 tasks done
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Comments
IslandRhythms
added
the
typescript
Types or Types-test related issue / Pull Request
label
Jul 19, 2023
The current type definition, as written, is correct for several reasons:
Thanks for the suggestion though 👍 |
Thanks for ur reply. Please reconside about this definition. Reasons you listed are not convincing.
|
vkarpov15
added a commit
that referenced
this issue
Aug 3, 2023
vkarpov15
added a commit
that referenced
this issue
Aug 8, 2023
types: add UpdateQueryKnownOnly type for stricter UpdateQuery type checking
We'll add a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
7.x
Node.js version
18.x
MongoDB server version
4.x
Typescript version (if applicable)
4.x
Description
The definition of type
UpdateQuery
is not very accurate cause code hint not work.Steps to Reproduce
The definition of types
UpdateQuery
for now:Typescript can not do code hint with using it, when you add some field not belong to this schema. Like this:
update({ test_field: 'test' })
It should get a types error, becausetest_field
is not a field of interfaceSchemaDemo
. TypesUpdateQuery
is an intersection type which includeAnyObject
, sotest_field
matchedAnyObject
. In a sense,UpdateQuery
make no senses for now.Expected Behavior
Don't use
AnyObject
, it make type system not work. If user want to do something about custom type, just use generic type to do that. I thinkUpdateQuery
should by defined like that:In this design, more flexibility for users. Usage case:
Tasks
The text was updated successfully, but these errors were encountered: