You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type definition for the Schema.query doesn't seems to be working
What is the expected behavior?
If I define a custom query for a schema, the this type is resolved to any. If I try to provide a custom this type I get a "Type 'T' is not assignable to type...":
// Type 'T' is not assignable to type 'Query<any, any, {}, any>'.ts(2322)SomeSchema.query.someQuery=function(this: QueryWithHelpers<ResultType,DocType>): QueryWithHelpers<ResultType,DocType>{return ...
}
This previously worked (when using @types/mongoose) defining this to DocumentQuery<ResultType, DocType> although they didn't have a type for the query property
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
5.13.5
The text was updated successfully, but these errors were encountered:
You're right that this is any by default in query helpers, we're working on that.
But, in the meantime, the below script seems to compile fine. Can you please provide your tsconfig and check whether the below script compiles on your setup?
bug
What is the current behavior?
The type definition for the
Schema.query
doesn't seems to be workingWhat is the expected behavior?
If I define a custom query for a schema, the
this
type is resolved toany
. If I try to provide a customthis
type I get a "Type 'T' is not assignable to type...":This previously worked (when using @types/mongoose) defining
this
toDocumentQuery<ResultType, DocType>
although they didn't have a type for the query propertyWhat are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
5.13.5
The text was updated successfully, but these errors were encountered: