Closed twibster closed 1 month ago
A solution to this problem is replacing the type parameter for RawDocType
from DocType
to unkown
to match mongoose Query declaration
interface Query<
ResultType,
DocType,
THelpers = NonNullable<unknown>,
RawDocType = unknown,
QueryOp = 'find',
TInstanceMethods = Record<string, never>,
> {
paginate<O extends PaginateOptions>(
options?: O
): Promise<PaginateResult<PaginateDocument<RawDocType, TInstanceMethods, O>>>
paginate<UserType = ResultType, O extends PaginateOptions = PaginateOptions>(
options?: O
): Promise<PaginateResult<PaginateDocument<UserType, TInstanceMethods, O>>>
paginate<UserType = ResultType>(
options?: PaginateOptions
): Promise<PaginateResult<PaginateDocument<UserType, TInstanceMethods, PaginateOptions>>>
}
also we can ignore the error by placing the following line before the interface:
// @ts-expect-error overwriting of mongoose Query interface
as in #221
Thanks for the fix. @twibster
Describe the bug On the latest version of mongoose (8.6.3), There is a difference in
RawDocType
parameter type (unknown
) in the Query class in mongoose.d.ts:and Query interface in index.d.ts (Ref to
DocType
) from the package here:which is causing an inconsistent declaration error in TypeScript
To Reproduce 1- building the application or whatever using the package and mongoose
Expected behavior A matching declaration of Query in the package and in mongoose