From 7124b76fe8c80da25443d7b4a35d608c08120041 Mon Sep 17 00:00:00 2001 From: David Ethell Date: Wed, 18 Dec 2024 16:50:42 -0500 Subject: [PATCH] feat(router): Update beforeEnter typing --- README.md | 2 +- lib/route-data.js | 2 +- router.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c9fcf1..46c9993 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ import RouteData from '@jack-henry/web-component-router/lib/route-data.js'; * These should match to named path segments. Each camel case name * is converted to a hyphenated name to be assigned to the element. * @param {boolean=} requiresAuthentication (optional - defaults true) - * @param {function():Promise=} beforeEnter Optionally allows you to dynamically import the component for a given route. The route-mixin.js will call your beforeEnter on routeEnter if the component does not exist in the dom. + * @param {function():(Promise|void)=} beforeEnter Optionally allows you to dynamically import the component for a given route. The route-mixin.js will call your beforeEnter on routeEnter if the component does not exist in the dom. */ const routeData = new RouteData( 'Name of this route', diff --git a/lib/route-data.js b/lib/route-data.js index 3280bbd..e7286a4 100644 --- a/lib/route-data.js +++ b/lib/route-data.js @@ -8,7 +8,7 @@ class RouteData { * @param {!Array=} namedParameters list in camelCase. Will be * converted to a map of camelCase and hyphenated. * @param {boolean=} requiresAuthentication - * @param {function():Promise=} beforeEnter + * @param {function():(Promise|void)=} beforeEnter */ constructor(id, tagName, path, namedParameters, requiresAuthentication, beforeEnter) { namedParameters = namedParameters || []; diff --git a/router.js b/router.js index 53a7c21..2daed52 100644 --- a/router.js +++ b/router.js @@ -23,7 +23,7 @@ * params: (Array|undefined), * authenticated: (boolean|undefined), * subRoutes: (Array|undefined), - * beforeEnter: (function():Promise|undefined) + * beforeEnter?: (function():Promise|void) * }} RouteConfig */ let RouteConfig;