Closed
Description
I have an object with an optional boolean field. It's passed to a function. I destructure the field, assigning false
if it's undefined
. I then combine it with the !
operator in an if-condition. The rule complains about an unexpected non-boolean.
Repro
{
"rules": {
"@typescript-eslint/strict-boolean-expressions": "error"
}
}
type Options = { field?: boolean }
function validate({ field = false }: Options) {
if (!field) {
// …
}
}
(To be fair the type of the function argument is inferred, but that's harder to express in a repro.)
Expected Result
No linter errors.
Actual Result
The rule complains that field
is a non-boolean.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
1.12.0 |
@typescript-eslint/parser |
1.12.0 |
TypeScript |
3.5.3 |
ESLint |
6.0.1 |
node |
X.Y.Z |
npm |
X.Y.Z |