From 72237c8317131c9c454e3a55e2d2f77e2ced9cc1 Mon Sep 17 00:00:00 2001 From: Paul Selden Date: Fri, 10 Nov 2017 12:16:51 -0500 Subject: [PATCH] [history] Add overloads for History.block History.block also accepts a string or a function which is used to determine the prompt. --- types/history/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/history/index.d.ts b/types/history/index.d.ts index 528ab7ff21..eb15aaa0fc 100644 --- a/types/history/index.d.ts +++ b/types/history/index.d.ts @@ -18,7 +18,7 @@ export interface History { go(n: number): void; goBack(): void; goForward(): void; - block(prompt?: boolean): UnregisterCallback; + block(prompt?: boolean | string | TransitionPromptHook): UnregisterCallback; listen(listener: LocationListener): UnregisterCallback; createHref(location: LocationDescriptorObject): Href; } @@ -48,6 +48,7 @@ export namespace History { export type Pathname = string; export type Search = string; export type TransitionHook = (location: Location, callback: (result: any) => void) => any; + export type TransitionPromptHook = (location: Location, action: Action) => string | false | void; export type Hash = string; export type Href = string; } @@ -60,6 +61,7 @@ export type Path = History.Path; export type Pathname = History.Pathname; export type Search = History.Search; export type TransitionHook = History.TransitionHook; +export type TransitionPromptHook = History.TransitionPromptHook; export type Hash = History.Hash; export type Href = History.Href;