You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.10.1
Node.js version
16
MongoDB server version
4.2
Typescript version (if applicable)
4.6.3
Description
When I execute findOne method on model I am getting type annotations like below:
The problem above is typescript assumes that result will be always there.
So, If latestRowEntry is null I am getting error accessing nested props(latestRowEntry.time).
Ideally, Typescript should not allow the access of nested properties without checking latestRowEntry is null or not.
The annotation that's getting generated is not correct.
The problem above is typescript assumes that result will be always there.
So, If latestRowEntry is null I am getting error accessing nested props(latestRowEntry.time).
Ideally, Typescript should not allow the access of nested properties without checking latestRowEntry is null or not.
The annotation that's getting generated is not correct.
The text was updated successfully, but these errors were encountered:
Prerequisites
Mongoose version
6.10.1
Node.js version
16
MongoDB server version
4.2
Typescript version (if applicable)
4.6.3
Description
When I execute
findOne
method on model I am getting type annotations like below:The problem above is typescript assumes that result will be always there.
So, If
latestRowEntry
is null I am getting error accessing nested props(latestRowEntry.time
).Ideally, Typescript should not allow the access of nested properties without checking
latestRowEntry
is null or not.The annotation that's getting generated is not correct.
Below is my model and it's interface
Steps to Reproduce
Use below model code and try to query using method
model#findOne
.Expected Behavior
The problem above is typescript assumes that result will be always there.
So, If
latestRowEntry
is null I am getting error accessing nested props(latestRowEntry.time
).Ideally, Typescript should not allow the access of nested properties without checking
latestRowEntry
is null or not.The annotation that's getting generated is not correct.
The text was updated successfully, but these errors were encountered: