From b4c953da52513dae73f4434708ae4bbb128a7bd4 Mon Sep 17 00:00:00 2001 From: spacejack Date: Fri, 25 Jan 2019 20:45:08 -0500 Subject: [PATCH] Additional signature for m.route.link --- types/mithril/index.d.ts | 5 +++-- types/mithril/test/test-route.ts | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/types/mithril/index.d.ts b/types/mithril/index.d.ts index 83de8c9825..86c20f57cd 100644 --- a/types/mithril/index.d.ts +++ b/types/mithril/index.d.ts @@ -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 Vnode's oncreate hook. */ - link(vnode: Vnode): (e?: Event) => any; + /** This method is meant to be used in conjunction with an Vnode's oncreate/onupdate hooks. */ + link(vnode: Vnode): (e?: Event) => any; + link(options: {replace: boolean}): (vnode: Vnode) => (e?: Event) => any; /** Returns the named parameter value from the current route. */ param(name: string): string; /** Gets all route parameters. */ diff --git a/types/mithril/test/test-route.ts b/types/mithril/test/test-route.ts index 030a260bcb..8cb2a21a21 100644 --- a/types/mithril/test/test-route.ts +++ b/types/mithril/test/test-route.ts @@ -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 = route.link({replace: true}); + +const ex1 = h('a', {href: '/url', oncreate: route.link}); + +const ex2 = h('a', {href: '/url', oncreate: route.link({replace: true})});