-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Cursor.next can return null, but TypeScript says it can't #14787
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
Comments
IslandRhythms
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
typescript
Types or Types-test related issue / Pull Request
labels
Aug 7, 2024
vkarpov15
removed
the
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
label
Aug 8, 2024
vkarpov15
added a commit
that referenced
this issue
Aug 10, 2024
types(cursor): indicate that cursor.next() can return null
This was referenced Sep 4, 2024
This was referenced Sep 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
6.13.0, 7.6.13, 8.5.2
Node.js version
20.12.2
MongoDB server version
6.0.16
Typescript version (if applicable)
5.5.4
Description
The
Cursor.next
method is documented to return null sometimes, but TypeScript thinks it always returns non-null.Steps to Reproduce
It failed to compile:
It also caused code like this to be flagged by TypeScript ESLint
@typescript-eslint/no-unnecessary-condition
rule:Expected Behavior
It should compile.
doc
could be null, so TypeScript should allow assigning null to it.The text was updated successfully, but these errors were encountered: