In versions of Lit >2, ifDefined can handle null and undefined so the explicit null check is no longer required.
Change
Instead of recommending ifDefined(expr === null ? undefined : expr), instead recommend ifDefined(expr) for both undefined and null.
Test
Added message tests to ensure that type detection works correctly, and that the diagnostic message correctly identify either null or undefined. This will make it easier to catch regressions when moving to isTypeAssignableTo in the future.
Context
Fixes: https://github.com/runem/lit-analyzer/issues/317
In versions of Lit >2,
ifDefined
can handlenull
andundefined
so the explicitnull
check is no longer required.Change
Instead of recommending
ifDefined(expr === null ? undefined : expr)
, instead recommendifDefined(expr)
for bothundefined
andnull
.Test
Added message tests to ensure that type detection works correctly, and that the diagnostic message correctly identify either
null
orundefined
. This will make it easier to catch regressions when moving toisTypeAssignableTo
in the future.