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

FindOneAndUpdate method options in @types/mongoose #8118

Closed
iamchathu opened this issue Aug 31, 2019 · 3 comments
Closed

FindOneAndUpdate method options in @types/mongoose #8118

iamchathu opened this issue Aug 31, 2019 · 3 comments

Comments

@iamchathu
Copy link

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

Bug

What is the current behavior?

omitUndefined and timestamps options are documented in Documentation but TypeScript QueryFindOneAndUpdateOptions interface doesn't have that options defined. So it doesn't allowed to use them with TypeScript.

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

  • Install Latest Mongoose and @types/mongoose
  • Write a method with findOneAndUpate with options either one or both omitUndefined or timestamps to be true.
  • Typescript will yell they are not defined in QueryFindOneAndUpdateOptions

What is the expected behavior?

To use omitUndefined and timestamps options in TypeScript enviroment.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

Node: v10.53.3
"mongoose": "^5.6.11"
"@types/mongoose": "^5.5.16"
"typescript": "^3.5.3",
@welljsjs
Copy link

welljsjs commented Sep 3, 2019

@iamchathu
I ran into the same problem. I think you need to report this issue to the DefinitlyTyped repo.

I just had a look over there and it seems like so already reported that problem in June. So far, no-one seems to have cared about that. However, you could support the bug by giving it a thumbs-up. That might raise some attention.

ALA they don't update it, I'd just use ts-ignore although that's not pretty:

model.findOneAndUpdate(conditions, update, {
  //@ts-ignore
  omitUndefined: true
});

@iamchathu
Copy link
Author

@welljsjs I have added my own types to project and fixed the issue. Also I sent a PR to DefinitlyTyped repo.

@Automattic Automattic locked as off-topic and limited conversation to collaborators Sep 4, 2019
@vkarpov15
Copy link
Collaborator

This project isn't @types/mongoose, that's DefinitelyTyped. Please follow #8108 for updates on typescript support - right now Mongoose doesn't have any official typescript support.

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

No branches or pull requests

3 participants