From 03e2cb64872f4cd5a1b12b2839ddde2ee65853e1 Mon Sep 17 00:00:00 2001 From: Rijk van Zanten Date: Thu, 6 Feb 2020 17:40:54 -0500 Subject: [PATCH 1/2] Update type of Route.name On very first load, `name` is `null`, not `string` or `undefined`. This means that either the passed route is wrong, or the type is incorrect. --- types/router.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/router.d.ts b/types/router.d.ts index 1d6135a6b..ed199f5a1 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -134,7 +134,7 @@ export interface Location { export interface Route { path: string - name?: string + name?: string | null hash: string query: Dictionary params: Dictionary From 252a368992877cbb6d04d36472cc5311fd71a615 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Fri, 7 Feb 2020 10:01:04 -0500 Subject: [PATCH 2/2] fix(tests): fix type test --- types/test/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/test/index.ts b/types/test/index.ts index b370c00da..7efdfbb24 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -113,7 +113,7 @@ const mode: string = router.mode const route: Route = router.currentRoute const path: string = route.path -const name: string | undefined = route.name +const name: string | undefined | null = route.name const hash: string = route.hash const query: string | (string | null)[] | null = route.query['foo'] const params: string = route.params['bar'] @@ -128,7 +128,7 @@ matched.forEach(m => { [key: string]: ComponentOptions | typeof Vue | AsyncComponent } = m.components const instances: { [key: string]: Vue } = m.instances - const name: string | undefined = m.name + const name: string | undefined | null = m.name const parant: RouteRecord | undefined = m.parent const redirect: RedirectOption | undefined = m.redirect })