Missmatch between undefined/null
See original GitHub issueIn index.d.ts (around line 153) it is stated that findOne, findOneAndDelete, and findOneAndUpdate return a Promise of the collection type, or undefined.
But in fact all of these return null, not undefined when no document is found.
This is quite annoying when using TypeScript, since it will error with Object is possibly undefined
if you do not check for this, but checking with !== undefined
only calms typescript down. It does nothing at runtime. However, checking with != undefined
, or checking if the object is truthy does work at both compiletime and runtime.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
The undefined vs null Pitfall in Javascript - The Code Ship
A property that has no definition is undefined, which also means no value, no type and never been referenced before in the scope....
Read more >Inconsistency between null and undefined · Issue #584 - GitHub
Hello. Great work. I'm running into following issue, given this entity class Ent { @PrimaryGeneratedColumn() id: number; @Column("varchar", ...
Read more >javascript - Can someone explain this simple concept of null ...
Simply, == only checks for value, whereas === checks for value as well as type of data. Here undefined and null both means...
Read more >7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
A detailed article about 'undefined' keyword in JavaScript. 7 tips on how to handle correctly 'undefined' and increase code durability.
Read more >JavaScript Fundamentals: Checking for null and undefined
The primitive values null and undefined have a distinct difference that should be used. But how to you tell the difference between a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Absolutely yes
yep, totally ok 👍