Open pygy opened 7 years ago
Yeah that would be handy as a convenience type to include. I think you'd still need to annotate it yourself:
m('button', {onclick: (e: m.Event) => {e.redraw = false}}, "Don't redraw!");
Unless we can do something clever with the Attrs
type...
Thinking about this a bit more, might be more useful to extend all possible events. It could be made more user friendly by adding these and these (and other...?) properties to Attrs
.
Eg:
export interface VEvent {
redraw: boolean
}
export interface Attrs {
// ...
onblur?: (this: HTMLElement, ev: FocusEvent & VEvent) => any;
onclick?: (this: HTMLElement, ev: MouseEvent & VEvent) => any;
// etc...
Here's a gist of everything I can think of at the moment:
https://gist.github.com/spacejack/73ae839c4a80a2dfaa88294caec3605f
I've added a new branch event-types
.
@isiahmeadows, @andraaspar what do you think: https://github.com/spacejack/mithril.d.ts/compare/event-types
LGTM :-)
LGTM, although I wish we could concatentate string keys with mapped types, so we wouldn't need to manage the big list ourselves... (TypeScript doesn't allow it though, sadly.)
Something I should point out about this change, if you're using external event handler functions, you'd need to annotate them like this: https://github.com/spacejack/mithril.d.ts/blob/event-types/test/test-api.ts#L649
@isiahmeadows Is it not solved by my proposal?: https://github.com/spacejack/mithril.d.ts/issues/24
Hey there :-)
It may be nice to have maybe a
Mithril.Event
with an addedredraw: boolean
field.Or did I miss it?