Skip to content
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

An issue with types on mongoose v5 #165

Closed
LosTigeros opened this issue Apr 12, 2022 · 10 comments
Closed

An issue with types on mongoose v5 #165

LosTigeros opened this issue Apr 12, 2022 · 10 comments

Comments

@LosTigeros
Copy link

LosTigeros commented Apr 12, 2022

Describe the bug
Hey, that's not really a bug, but some type errors. To be exact, these:

> tsc
node_modules/mongoose-paginate-v2/index.d.ts:23:35 - error TS2694: Namespace '"node_modules/@types/mongodb/index"' has no exported member 'CollationOptions'. 

23     collation?: import('mongodb').CollationOptions | undefined;
                                     ~~~~~~~~~~~~~~~~

node_modules/mongoose-paginate-v2/index.d.ts:74:7 - error TS2304: Cannot find name 'HydratedDocument'.

74     : HydratedDocument<T, TMethods, TVirtuals>;
         ~~~~~~~~~~~~~~~~


Found 2 errors.

To Reproduce

  1. Install legacy version of mongoose (latest is 5.13.14) and latest version of mongoose-paginate-v2:
    yarn add [email protected] mongoose-paginate-v2
  2. Create a sample file with imports of mongoose and mongoose-paginate-v2:
    index.ts:
import { Mongoose } from "mongoose";
import { paginate } from "mongoose-paginate-v2";
  1. Try to transpile that file by using tsc:
    > tsc .\index.ts

Expected behavior
TSC should transpile the file without returning any type errors.

Screenshots
image

Desktop (please complete the following information):
Not needed

Smartphone (please complete the following information):
Not needed

Additional context
If it helps you with anything, I'm using yarn instead of npm.

@aravindnc
Copy link
Owner

@LosTigeros Please use below version for Mongoose 5.
https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mongoose-paginate-v2

Let me know if this helps.

@jdhiro
Copy link

jdhiro commented Apr 28, 2022

@aravindnc that link isn't working. What's the specific version to use?

@aravindnc
Copy link
Owner

@LosTigeros
Copy link
Author

LosTigeros commented Apr 29, 2022

After installing it, I'm getting a lot of these:

error TS2717: Subsequent property declarations must have the same type. 
error TS2374: Duplicate index signature for type 'string'.
error TS2300: Duplicate identifier 'PaginateDocument'.

log.txt

So this is not a solution

@aravindnc
Copy link
Owner

aravindnc commented Apr 29, 2022 via email

@LosTigeros
Copy link
Author

I created that issue because I wanted to use the latest version of this package. It doesn't say anywhere that >= 1.6.0 is not compatible with v5 anymore. If this issue won't be fixed, please at least state somewhere that, mongoose-paginate-v2 >=1.6.0 is not compatible with legacy version of mongoose (v5).

@jdhiro
Copy link

jdhiro commented Jul 16, 2022

I had put off upgrading to the latest version of mongoose, and hence this library, because I was getting a ton of type errors when trying to update...

Until I realized that my @types/node was @10 instead of @16. Updating that one thing got rid of almost all of my type errors with both Mongoose and this package. YMMV.

@aravindnc
Copy link
Owner

aravindnc commented Oct 11, 2022 via email

@liyaodong
Copy link

// tsconfig.json
skipLibCheck: true

This can avoid the build error but I don't think that's a solution.

@aravindnc
Copy link
Owner

Please reopen if the issue exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants