MithrilJS / mithril.d.ts

Types for mithril.js
MIT License
80 stars 11 forks source link

RouteResolver.onmatch signature too restrictive #8

Closed russgray closed 7 years ago

russgray commented 7 years ago

In v1.0.1 the onmatch signature was changed to only allow a Promise to be returned if it was a Promise<Component<any, any>>. I believe this is too restrictive - see the mithril docs at http://mithril.js.org/route.html#preloading-data for an example of using a Promise returned by m.request to defer rendering a component until data is loaded.

I think this is as simple as changing the onmatch signature to allow Promise<any>, like so:

onmatch?: (args: any, requestedPath: string) => Mithril.Component<any,any> | Promise<any> | void;

Let me know what you think. I can do it myself and raise a PR if you like.

spacejack commented 7 years ago

Yup, sounds good. I've made a fix, you can install github:spacejack/mithril.d.ts#1.0.2