Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lit-extended & HTMLElementTagNameMap integration #5

Open
justinfagnani opened this issue Oct 12, 2017 · 1 comment
Open

lit-extended & HTMLElementTagNameMap integration #5

justinfagnani opened this issue Oct 12, 2017 · 1 comment
Labels
help wanted Issues identified as good community contribution opportunities

Comments

@justinfagnani
Copy link

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.

@mjbvz mjbvz added the help wanted Issues identified as good community contribution opportunities label Oct 15, 2017
@tomsdev
Copy link

tomsdev commented Feb 17, 2018

Would be great to make the type definitions extensible the same way that JSX in Typescript is extensible:

declare namespace JSX {
  interface ElementAttributesProperty {
    props: {}; // specify the property name to use
  }
  interface IntrinsicElements {
    'my-element': MyElement;
  }
}

See the full TSX documentation: https://www.typescriptlang.org/docs/handbook/jsx.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

3 participants