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

Export DocumentQuery for backwards compatibility #10036

Closed
zeeshanalisyed opened this issue Mar 18, 2021 · 4 comments
Closed

Export DocumentQuery for backwards compatibility #10036

zeeshanalisyed opened this issue Mar 18, 2021 · 4 comments
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@zeeshanalisyed
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Not sure, because of two typing files which is one from this same project and one is @types/mongoose because of that was having an import error of DocumentQuery import. Not Sure which typing file should I use, now if I remove index.d.ts file from the node_modules/mongoose this error is not coming up anymore, because @types/mongoose have DocumentQuery export.

If the current behavior is a bug, please provide the steps to reproduce.

Code

import { 
   Document, 
   DocumentQuery, // this import is giving an error that it is not exported
} from "mongoose";
tsconfig.json
{
  "compilerOptions": {
    "outDir": "dist",
    "esModuleInterop": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "pretty": true,
    "types": [
      "jest",
      "node"
    ],
    "typeRoots" : [
      "node_modules/@types",
      "src/types"
    ],
    "sourceMap": true,
    "target": "es6",
    "baseUrl": "./",
    "lib": [
      "ES2019"
    ]
  },
  "exclude": [
    "node_modules",
  ]
}

What is the expected behavior?
Not Sure, don't know which typing file is the final one.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
this is not related to any of these but still I will include the versions below.
Node.js: 14.16.0
Mongoose: 5.12.0
MongoDB: 3.4

@vkarpov15
Copy link
Collaborator

You should use the Mongoose index.d.ts, not @types/mongoose, unless you have a good reason to.

Why are you using DocumentQuery instead of just Query?

@vkarpov15 vkarpov15 added the help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary label Mar 19, 2021
@zeeshanalisyed
Copy link
Author

You should use the Mongoose index.d.ts, not @types/mongoose, unless you have a good reason to.

Why are you using DocumentQuery instead of just Query?

I am not using that myself it is being used in one of the dependencies in my project so maybe I will correct them that also helps, I will create a PR on their project.
Thank you for your help, I am going to close this.

@vkarpov15
Copy link
Collaborator

We'll add a DocumentQuery export for backwards compatibility. Can you please let me know which dependency this is?

@vkarpov15 vkarpov15 added typescript Types or Types-test related issue / Pull Request and removed help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary labels Mar 23, 2021
@vkarpov15 vkarpov15 added this to the 5.12.3 milestone Mar 23, 2021
@vkarpov15 vkarpov15 changed the title Which one is the main typing file is it file from this project or @types/mongoose? Export DocumentQuery for backwards compatibility Mar 31, 2021
@gusperandio
Copy link

Thanks @zeeshanalisyed !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

3 participants