From 8f831f28f33bb766d5baaabc8b2daff259f3d45b Mon Sep 17 00:00:00 2001 From: Rijk van Zanten Date: Fri, 7 Feb 2020 10:31:52 -0500 Subject: [PATCH] fix(ts): add null to Route.name (#3117) * 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. * fix(tests): fix type test --- types/router.d.ts | 2 +- types/test/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 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 })