this type in define helper is too strict #6

Closed
opened 2026-01-13 15:15:41 +00:00 by endeavorance · 1 comment
Owner

Inherited HTMLElement properties are not showing as valid via TypeScript evaluation when defining functions using the define() helper. As such, you cannot use this.hasAttribute without casting this first.

Minimum reproduction

define("some-component", {
  script() {
    console.log(this.hasAttribute("example")); // TypeScript will flag this
  }
});
Inherited HTMLElement properties are not showing as valid via TypeScript evaluation when defining functions using the `define()` helper. As such, you cannot use `this.hasAttribute` without casting `this` first. ## Minimum reproduction ``` define("some-component", { script() { console.log(this.hasAttribute("example")); // TypeScript will flag this } }); ```
endeavorance added this to the 0.2.0 milestone 2026-01-13 15:16:01 +00:00
Author
Owner

Red herring: this only occurs when there is no "DOM" lib configured in tsconfig

Closing, but should consider a warning if not configured properly. Also should make a template with the correct configs.

Red herring: this only occurs when there is no "DOM" lib configured in `tsconfig` Closing, but should consider a warning if not configured properly. Also should make a template with the correct configs.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rusticarcade/palette#6
No description provided.