Closed as not planned
Closed as not planned
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
const foobar = async (func?: () => null) => {
const finalFunc =
func ||
(() => null);
return finalFunc();
};
ESLint Config
module.exports = {
"rules": {"@typescript-eslint/strict-boolean-expressions": ["error", {
"allowString": false,
"allowNumber": false,
"allowNullableObject": false,
"allowNullableBoolean": false,
"allowNullableString": false,
"allowNullableNumber": false,
"allowNullableEnum": false,
"allowAny": false,
"allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": false
}]}
}
tsconfig
Expected Result
The auto fix introduces a bug in this case, as it replaces func || (() => null);
with func != null || (() => null);
which is now either a boolean or a function, when the original code was such that it always resulted in a function.
In this case there should be no auto fix, or the actual fix is to use nullish coalescing (func ?? (() => null);
), but that seems a bit beyond the scope of this rule...
Actual Result
The auto fix introduces a bug in this case, as it replaces func || (() => null);
with func != null || (() => null);
which is now either a boolean or a function, when the original code was such that it always resulted in a function.
Additional Info
No response