You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 2, 2024. It is now read-only.
Some forks of the hyperscript function recognise lifecycle methods as potential matches on the attrs input, but other than that, AFAICT, the interface is an Any — so unless the author is reaching for a lifecycle method, the contents of attrs are completely freeform, with no hints.
But there is a lot of further domain complexity to what can be described in attrs, and we could make the IDE experience much more powerful out of the box by providing hints for authors that describe some of these domains.
The matching sequence for Attrs ought IMO to behave as follows for the DOM element fork of the hyperscript function (non-element hyperscript forks are not affected by this proposal):
LifecycleMethod | Style | EventHandler | ElementProperty | Any
The remaining magic attribute, key, is of type Any anyway so merits no special consideration.
ElementProperty is AFAICT directly referencible via TypeScripts built-ins (Element is used to qualify vnode.dom in current types).
EventHandler is the type I think would bring the most value 👇
@boazblake spent a while looking for some logic design mistake in some code; but eventually it turned out to be an easily-missed typo — onclick: {/*contents*/} instead of onclick: () => {/*contents*/}. Exposing the type semantics for on-prefixed keys as being proxied to the DOM EventHandler interface would have caught this early. It turns out this is possible in TypeScript using the recent syntax addition:
Some forks of the hyperscript function recognise lifecycle methods as potential matches on the
attrsinput, but other than that, AFAICT, the interface is anAny— so unless the author is reaching for a lifecycle method, the contents ofattrsare completely freeform, with no hints.But there is a lot of further domain complexity to what can be described in
attrs, and we could make the IDE experience much more powerful out of the box by providing hints for authors that describe some of these domains.The matching sequence for
Attrsought IMO to behave as follows for the DOM element fork of the hyperscript function (non-element hyperscript forks are not affected by this proposal):key, is of typeAnyanyway so merits no special consideration.ElementPropertyis AFAICT directly referencible via TypeScripts built-ins (Elementis used to qualifyvnode.domin current types).Styleis its own discrete type, @panoply has this covered in Types for vnode style attribute #46EventHandleris the type I think would bring the most value 👇@boazblake spent a while looking for some logic design mistake in some code; but eventually it turned out to be an easily-missed typo —
onclick: {/*contents*/}instead ofonclick: () => {/*contents*/}. Exposing the type semantics foron-prefixed keys as being proxied to the DOM EventHandler interface would have caught this early. It turns out this is possible in TypeScript using the recent syntax addition:I’ve never written TypeScript day to day but figure we could merge something like that 👆 into a rewritten
Attributes.If we can merge these things together without building an inheritance hierarchy, so much the better.
@spacejack what do you think?
External sources: