runem / lit-analyzer

Monorepository for tools that analyze lit-html templates
MIT License
314 stars 35 forks source link

Assignment incorrectly flagged as invalid #356

Open dstoc opened 2 months ago

dstoc commented 2 months ago

Repro:

import {LitElement, html} from 'lit';
import {customElement, property} from 'lit/decorators.js';

interface A {
  a: number;
}

interface B {
  b: number;
}

@customElement('test-element')
export class Test extends LitElement {
  @property({attribute: false}) prop?: A & B;
  override render() {
    return html` <test-element .prop=${this.prop!}></test-element> `;
  }
}

Error:

    Type 'A & B' is not assignable to 'A & B | undefined'
    16:  n html` <test-element .prop=${this.prop!}></test-e
    no-incompatible-type-binding

lit-analyzer@2.0.3