-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Strict Projection Object Typing #15327
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
Changes from 11 commits
2780189
2ce0ce2
8e482ef
6ad9293
df08fc7
83fc8f6
5b11b44
9daf0ca
e94956b
0c1d13a
66665e3
3ff4f4d
3f43612
05e2a45
ed36d2d
19b490d
ac66c7b
d94f1b7
002d518
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,7 @@ declare module 'mongoose' { | |
updatedAt?: boolean; | ||
} | ||
|
||
interface QueryOptions<DocType = unknown> extends | ||
interface QueryOptions<DocType = any> extends | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isnt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is true. The projection is passed like this, I am not sure why the projection is used in this interface(or if anyone uses this, instead of passing it as the second - because you are already passing the projection as one argument). it causes some circular reference as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hasezoey Just added a new commit. leaving the I am trying to find out why Typegoose is facing errors, the one that I get is this one: Type 'Model<ObtainDocumentType<any, DocumentType<InstanceType<U & Func>>, ResolveSchemaOptions<DefaultSchemaOptions>>, ... 4 more ..., Schema<...>>' is not assignable to type 'Model<any, {}, {}, {}, any, any>'.
The types returned by 'findById(...).exec()' are incompatible between these types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that is the error i could not figure out why it was happening. |
||
PopulateOption, | ||
SessionOption { | ||
arrayFilters?: { [key: string]: any }[]; | ||
|
@@ -160,7 +160,7 @@ declare module 'mongoose' { | |
* Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators. | ||
*/ | ||
overwriteImmutable?: boolean; | ||
projection?: ProjectionType<DocType>; | ||
projection?: ProjectionType<any>; | ||
/** | ||
* if true, returns the full ModifyResult rather than just the document | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to see a test of using
as ProjectionType<>
to explicitly cast in case the type checking is incorrect for some reason (or if user is dealing with 5-level deep path)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vkarpov15
something like this you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
19b490d