Additional signature for m.route.link

This commit is contained in:
spacejack
2019-01-25 20:45:08 -05:00
parent 89592f7ec3
commit b4c953da52
2 changed files with 10 additions and 3 deletions
+3 -2
View File
@@ -94,8 +94,9 @@ declare namespace Mithril {
set(route: string, data?: any, options?: RouteOptions): void;
/** Defines a router prefix which is a fragment of the URL that dictates the underlying strategy used by the router. */
prefix(urlFragment: string): void;
/** This method is meant to be used in conjunction with an <a> Vnode's oncreate hook. */
link(vnode: Vnode<any, any>): (e?: Event) => any;
/** This method is meant to be used in conjunction with an <a> Vnode's oncreate/onupdate hooks. */
link(vnode: Vnode<any, any>): (e?: Event) => any;
link(options: {replace: boolean}): (vnode: Vnode<any, any>) => (e?: Event) => any;
/** Returns the named parameter value from the current route. */
param(name: string): string;
/** Gets all route parameters. */
+7 -1
View File
@@ -125,4 +125,10 @@ route.set('/test2', undefined, {
const path: string = route.get();
const fn = route.link(h('div', 'test'));
const fn1: (e?: Event) => any = route.link(h('div', 'test'));
const fn2: (v: Vnode<any, any>) => any = route.link({replace: true});
const ex1 = h('a', {href: '/url', oncreate: route.link});
const ex2 = h('a', {href: '/url', oncreate: route.link({replace: true})});