MithrilJS / mithril.d.ts

Types for mithril.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RouteResolver.onmatch signature too restrictive

russgray opened this issue · comments

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.

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