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 Documentation Request Please Confirm You Have Done The Following...
- I have looked for existingopen or closed documentation requests that match my proposal.
- I haveread the FAQ and my problem is not listed.
Suggested Changes
The doc for the optionallowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing
in the ruleprefer-optional-chain
seems to provide incorrect examples. The original code goes following:
declare const foo: { bar: boolean } | null | undefined;declare function acceptsBoolean(arg: boolean): void;// ✅ typechecks succesfully as the expression only returns `boolean`acceptsBoolean(foo != null && foo.bar);// ❌ typechecks UNSUCCESSFULLY as the expression returns `boolean | undefined`acceptsBoolean(foo != null && foo.bar);
But the two lines callingacceptsBoolean
are equal. It seems like a copy-paste error. I think the second line should beacceptsBoolean(foo?.bar)
perhaps?