Convert && to if statement
condition && aFunction(); and similar expression statements into if statements.
Why is this refactoring helpful?
When checking that the leading part of an expression is not nullish, optional chaining is shorter and easier to understand:
anObject && anObject.f();
When testing a more general statement, an explicit
if is often a more readable alternative:
condition && (myVariable = value);
if (condition) myVariable = value;
- Code Assist ID (for the configuration file):
- You can configure custom keyboard shortcuts with these code action kinds:
- This code assist provides refactoring suggestions. Learn how to configure the refactoring suggestion visibility.