p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

Optional chaining conversion issue #16

Closed verccety closed 2 years ago

verccety commented 2 years ago

P42 tooltip (v1.101.1)

You can shorten 'this.control && this.control.invalid && this.control.touched' expression with optional chaining.p42 use-optional-chaining

  return this.control && this.control.invalid && this.control.touched;

P42 suggests incorrectly to convert into

return this.control?.invalid?.touched;
lgrammel commented 2 years ago

Thanks for the bug report! I'll update once I have a fix.

lgrammel commented 2 years ago

@verccety I've reworked the optional chaining refactoring in v1.103.0 and fixed the bug. Please re-open this issue if you still encounter the bug in v1.103 or higher. Thanks again for the bug report!