Skip to content

Commit

Permalink
fix(ts): add null to Route.name (#3117)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rijkvanzanten committed Feb 7, 2020
1 parent 38e6ccd commit 8f831f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion types/router.d.ts
Expand Up @@ -134,7 +134,7 @@ export interface Location {

export interface Route {
path: string
name?: string
name?: string | null
hash: string
query: Dictionary<string | (string | null)[]>
params: Dictionary<string>
Expand Down
4 changes: 2 additions & 2 deletions types/test/index.ts
Expand Up @@ -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']
Expand All @@ -128,7 +128,7 @@ matched.forEach(m => {
[key: string]: ComponentOptions<Vue> | 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
})
Expand Down

0 comments on commit 8f831f2

Please sign in to comment.