lit-analyzer icon indicating copy to clipboard operation
lit-analyzer copied to clipboard

The `ifDefined` directive should return a non-null type, not just non-`undefined`.

Open bicknellr opened this issue 1 year ago • 1 comments

The return type of ifDefined is determined with a special rule here:

https://github.com/runem/lit-analyzer/blob/92c084da4d33d6fbdd8b29603d2003387e65dbb3/packages/lit-analyzer/src/lib/rules/util/directive/get-directive.ts#L45-L63

But the analyzer doesn't realize that the return type can't be null in Lit 2, because it only removes undefined (matching Lit 1's behavior):

https://github.com/runem/lit-analyzer/blob/92c084da4d33d6fbdd8b29603d2003387e65dbb3/packages/lit-analyzer/src/lib/rules/util/directive/get-directive.ts#L52

bicknellr avatar Jan 11 '23 23:01 bicknellr