Describe the bug
When using the on:event syntax on HTML elements in JSX in TypeScript the props are considered invalid:
<div on:click={() => null} />
(JSX attribute) on:click: () => null
Type '{ "on:click": () => null; }' is not assignable to type 'HTMLAttributes<HTMLDivElement>'.
Property 'on:click' does not exist on type 'HTMLAttributes<HTMLDivElement>'. Did you mean 'onclick'?ts(2322)
Expected behavior
The behaviour of on:[event] handlers should be typed correctly. I've tried extending the HTMLElement interface to allow this, but I'm stuck with being unable to correctly:
interface HTMLElement {
[prop: `on:${keyof HTMLElementEventMap}`]: <
T extends keyof HTMLElementEventMap
>(
ev: HTMLElementEventMap[T]
) => void;
}
Unfortunately, the error with this type seems to suggest that I'd have to write out each individual on:${event} JSX handler, unless someone can suggest how to create a mapped type from the keys presented above. Before I attempt that, would this type extension belong in solidjs or dom-expressions?
Describe the bug
When using the
on:eventsyntax on HTML elements in JSX in TypeScript the props are considered invalid:Expected behavior
The behaviour of
on:[event]handlers should be typed correctly. I've tried extending theHTMLElementinterface to allow this, but I'm stuck with being unable to correctly:Unfortunately, the error with this type seems to suggest that I'd have to write out each individual
on:${event}JSX handler, unless someone can suggest how to create a mapped type from the keys presented above. Before I attempt that, would this type extension belong insolidjsordom-expressions?