Skip to content

Commit 8f831f2

Browse files
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
1 parent 38e6ccd commit 8f831f2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

types/router.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export interface Location {
134134

135135
export interface Route {
136136
path: string
137-
name?: string
137+
name?: string | null
138138
hash: string
139139
query: Dictionary<string | (string | null)[]>
140140
params: Dictionary<string>

types/test/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const mode: string = router.mode
113113

114114
const route: Route = router.currentRoute
115115
const path: string = route.path
116-
const name: string | undefined = route.name
116+
const name: string | undefined | null = route.name
117117
const hash: string = route.hash
118118
const query: string | (string | null)[] | null = route.query['foo']
119119
const params: string = route.params['bar']
@@ -128,7 +128,7 @@ matched.forEach(m => {
128128
[key: string]: ComponentOptions<Vue> | typeof Vue | AsyncComponent
129129
} = m.components
130130
const instances: { [key: string]: Vue } = m.instances
131-
const name: string | undefined = m.name
131+
const name: string | undefined | null = m.name
132132
const parant: RouteRecord | undefined = m.parent
133133
const redirect: RedirectOption | undefined = m.redirect
134134
})

0 commit comments

Comments
 (0)