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

Allow setting directive to undefined

Open nmattia opened this issue 1 year ago • 0 comments

I often set a directive as potentially undefined:

`<hgroup
      ${shouldDoSomething ? ref(() => doSomething()) : undefined}
  >...</hgroup>
`

lit-analyzer flags this as incorrect:

    Type 'DirectiveResult<DirectiveClass> | undefined' is not a Lit 2 directive'
    ...
    no-incompatible-type-binding

is this use case really incorrect? In practice it seems that lit is happy with it and just drops the directive. This is much simpler than e.g. writing two different hgroups above (with only the directive being different between the two) and using one or the other.

nmattia avatar Jan 08 '24 16:01 nmattia