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
typeT1={y:()=>number}|null;declareconstx1:T1;x1?.y()?.toExponential();// ^^// Error expected for unnecessary optional chaining.typeT2=(()=>number)|undefined;declareconstx2:T2;x2?.()?.toExponential();// ^^// Error expected for unnecessary optional chaining.typeT3={y:number}|null;declareconstx3:T3;x3?.y?.toExponential();// ^^// Error correctly caught.typeT4=()=>number;declareconstx4:T4;x4()?.toExponential;// ^^// Error correctly caught.
ESLint Config
module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-unnecessary-condition":"error",},};
tsconfig
{"compilerOptions": {"strictNullChecks":true }}
Expected Result
On lines 3 and 9, I expected there to be an error when using optional chaining on the return value of a method that returns a non-null and non-undefined value following another optional chaining.
Actual Result
On lines 3 and 9, no error was reported.