Optional chaining should be preferred (typescript:S6582)
SonarQube analysis of your Typescript code can trigger the following warning. Optional chaining sho
SonarQube analysis of your Typescript code can trigger the following warning.
Optional chaining should be preferred (typescript:S6582)
This warning is typically triggered when you have written code that looks like below.
{links && links.map((link, index) => (
As you can see that the code is trying to check if links variable has a valid (not null/undefined) value before it iterates over the collection. This code can be simplified by chaining the check. You can write the above code as below to fix the warning.
{links?.map((link, index) => (