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

Type errors in Components #2

Open
agawley opened this issue Jan 17, 2025 · 0 comments
Open

Type errors in Components #2

agawley opened this issue Jan 17, 2025 · 0 comments

Comments

@agawley
Copy link

agawley commented Jan 17, 2025

When I try to make a component, I get some type errors that make it look like TS doesn't understand that CustomElement extends HTMLElement. For example in this code:

/* globals customElements */
import CustomElement from "@enhance/custom-element";

export default class TestComponent extends CustomElement {
  constructor() {
    super();
  }

  connectedCallback() {
    this.addEventListener("change", () => {});
  }

  render({ html }) {
    return html`
      <div>
        <input type="text" />
      </div>
    `;
  }
}

customElements.define("my-component", TestComponent);

I get an error on addEventListener and on TestComponent inside customElements.define

Errors are
Property 'addEventListener' does not exist on type 'TestComponent'.

Argument of type 'typeof TestComponent' is not assignable to parameter of type 'CustomElementConstructor'.
  Type 'TestComponent' is missing the following properties from type 'HTMLElement': accessKey, accessKeyLabel, autocapitalize, dir, and 302 more.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant