Using TypeScript 3.9.5 I've encountered TS error:
TS2365: Operator '!==' cannot be applied to types 'false' and 'true'
Simplified example (code doesn't doing anything, but represents the flow of the actual function):
function _huh() {
let allStatementsMatched = true
let invoiceIIDsToApply = []
if (_.isEmpty(invoiceIIDsToApply) === false) {
invoiceIIDsToApply.forEach(x => {
if (x.name === 'test') {
allStatementsMatched = false
}
})
// Why does the below statement result in error: TS2365?
if (allStatementsMatched === false) {
}
}
}
I've found several github issues discussing this, but they all deal with more complex scenarios and I'm unable to see how they apply to my very simple example.
Why is typescript not treating a boolean like a boolean? Where is 'true' and 'false' coming from?