Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
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 havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
functionexample<Textendsobject>(arg:T,key:keyofT):void{constb1=arg[key]!=null;constb2=arg[key]??'fallback';}consto:{foo:string|null}={foo:null};example(o,'foo');
ESLint Config
module.exports={"rules":{"@typescript-eslint/no-unnecessary-condition":"error"}};
tsconfig
{"compilerOptions": {"strict":true }}
Expected Result
No error should be reported since it is possible to supply null values on properties of the incoming object in the example.
Actual Result
An error gets reported saying that null and the value of the type that it is compared with does not have any overlap:
Unnecessary conditional, the types have no overlap. 5:14 - 5:30Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined. 6:14 - 6:22
Additional Info
No response