Polymer / pwa-helpers

Small helper methods or mixins to help you build web apps.
BSD 3-Clause "New" or "Revised" License
439 stars 48 forks source link

Extending LitElement to class with connect-mixin causes ts-error #62

Closed KimPersson closed 5 years ago

KimPersson commented 5 years ago

I'm bumping in to a issue where following error Argument of type 'typeof LitElement' is not assignable to parameter of type 'Constructor<CustomElement>. Cannot assign an abstract constructor type to a non-abstract constructor type.

I have seen similar setups be done in other projects without problems but most of them are written with vanilla Javascript whereas i'm using Typescript.

I am not sure if its the mixin's types that aren't generic enough or how this problem is caused.

Here is a simple demo of my component

export class MyElement extends connect(store)(LitElement) {

  connectedCallback() {
    super.connectedCallback();
  }

  stateChanged(state: any) {
    this.activeTitle= state.activeTitle;
  }

  render() {
    return html`
    <h2>${ this.activeTitle}</h2>
    `;
  }
}
window.customElements.define('my-element', MyElement);