Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Property 'redraw' does not exist on type 'Event' #17

Open
pygy opened this issue Apr 4, 2017 · 8 comments
Open

Property 'redraw' does not exist on type 'Event' #17

pygy opened this issue Apr 4, 2017 · 8 comments
Assignees

Comments

@pygy
Copy link
Member

pygy commented Apr 4, 2017

Hey there :-)

It may be nice to have maybe a Mithril.Event with an added redraw: boolean field.

Or did I miss it?

@spacejack
Copy link
Collaborator

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...

@spacejack
Copy link
Collaborator

spacejack commented Apr 11, 2017

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...

@spacejack
Copy link
Collaborator

Here's a gist of everything I can think of at the moment:

https://gist.github.com/spacejack/73ae839c4a80a2dfaa88294caec3605f

@spacejack
Copy link
Collaborator

I've added a new branch event-types.

@isiahmeadows, @andraaspar what do you think: https://github.com/spacejack/mithril.d.ts/compare/event-types

@pygy
Copy link
Member Author

pygy commented Apr 12, 2017

LGTM :-)

@dead-claudia
Copy link
Member

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.)

@spacejack spacejack self-assigned this Apr 26, 2017
@spacejack
Copy link
Collaborator

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

@oldrich-s
Copy link

@isiahmeadows Is it not solved by my proposal?: #24

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants