Here is the condition:
const isSameProjectAsPreviousIntervention = Boolean(
intervention.projectId &&
previousIntervention?.projectId?.toString() ===
intervention.projectId.toString(),
);
currently, typescript-eslint does not report any issue, which is correct. tsgolint report an issue:
× typescript-eslint(prefer-optional-chain): Prefer using an optional chain expression instead, as it's more concise and easier to read.
80 │ const isSameProjectAsPreviousIntervention = Boolean(
81 │ ╭─▶ intervention.projectId &&
82 │ │ previousIntervention?.projectId?.toString() ===
83 │ ╰─▶ intervention.projectId.toString(),
84 │ );
╰────
If written like this:
const isSameProjectAsPreviousIntervention = previousIntervention?.projectId?.toString() ===
intervention?.projectId?.toString();
and if both intervention.projectId and previousIntervention?.projectId are null, isSameProjectAsPreviousIntervention is true, but it should be false.
Here is the condition:
currently, typescript-eslint does not report any issue, which is correct. tsgolint report an issue:
If written like this:
and if both
intervention.projectIdandpreviousIntervention?.projectIdarenull,isSameProjectAsPreviousInterventionis true, but it should be false.