Skip to content

Property 'paginateSubDocs' does not exist error when using typescipt #181

Open
@A-Ghattas

Description

@A-Ghattas

Describe the bug
Property 'paginateSubDocs' does not exist while paginate works correctly when using mongoose-paginate-v2 in a typescript project

To Reproduce
Add mongoose-paginate-v2 to a typescript project
Add it as a plugin to one of the schema
Add PaginateModel as an extenion of your model
Call paginateSubDocs (For exemple User.paginateSubDocs(...))

Expected behavior
paginateSubDocs should be a recognized method of type PaginateModel

Additional context
I think the solution is to add the method declaration in the file index.d.ts inside of the interface paginateModel in line 102 because the only declared method here is paginate

interface PaginateModel<T, TQueryHelpers = {}, TMethods = {}>
    extends Model<T, TQueryHelpers, TMethods> {
    paginate<O extends PaginateOptions>(
      query?: FilterQuery<T>,
      options?: O,
      callback?: (
        err: any,
        result: PaginateResult<PaginateDocument<T, TMethods, O>>
      ) => void
    ): Promise<PaginateResult<PaginateDocument<T, TMethods, O>>>;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions