I have been looking at using typescript with mongoose for MongoDB. Mostly it has been working great, but with certain types of quesites I get warnings from the typescript compiler.
If I do an or like so:
{"$or": [{done: {"$exists": false}}, {done:false}]}
I get the following warning:
Incompatible types in array literal expression: Types of property 'done' of types '{ done: { $exists: bool; }; }' and '{ done: bool; }' are incompatible.
I understand why, but is there a way to express this so the compiler will accept it?
You can type-assert any of the elements to
anyto “turn off” type checking:Or, if you’re initializing a variable, you can do something like this: