Skip to content

lit-extended & HTMLElementTagNameMap integration #5

Open
@justinfagnani

Description

@justinfagnani

lit-extended sets properties instead of attributes by default, and adds the name$= syntax for opting-into attributes.

If would be great to understand the set of valid properties and their types from HTMLElementTagNameMap. Integration with custom elements would be relatively easy then:

import {html, render} from 'lit-html/lib/lit-extended';

class MyElement extends HTMLElement {
  someProp: number;
}
customElements.define('my-element', HTMLElement);
declare global {
  interface HTMLElementTagNameMap {
    'my-element': MyElement;
  }
}

// this should have a warning under "${'abc'}" for not being a number
html`
  <my-element someProp=${'abc'}></my-element>
`;

// this should have a warning under somProp for not being property of MyElement
html`
  <my-element somProp=${10}></my-element>
`;

// this should have a warning under<my-elemet> for not being a known element
html`
  <my-elemet></my-elemet>
`;

Basically, we want the same features as JSX type-checking. Additionally, it'd be great to have some way to tell tsc the valid attributes for an element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues identified as good community contribution opportunities

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions