-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Description
Version
3.4.9
Reproduction link
https://codesandbox.io/s/cranky-resonance-psvmb?file=/main.ts
Steps to reproduce
import Router from 'vue-router'
const router = new Router()
router.beforeEach((to, from, next) => {
next(to) // errors at this line
})
What is expected?
no type errors
What is actually happening?
TS2345: Argument of type 'Route' is not assignable to parameter of type 'string | false | void | Location | ((vm: Vue) => any) | undefined'. Type 'Route' is not assignable to type 'Location'. Types of property 'name' are incompatible. Type 'string | null | undefined' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.
Can u remove null
in properties of name
in type of Route
or add it to the one of Location
// router.d.ts
export interface Location {
name?: string
path?: string
hash?: string
query?: Dictionary<string | (string | null)[] | null | undefined>
params?: Dictionary<string>
append?: boolean
replace?: boolean
}
export interface Route {
path: string
name?: string | null
hash: string
query: Dictionary<string | (string | null)[]>
params: Dictionary<string>
fullPath: string
matched: RouteRecord[]
redirectedFrom?: string
meta?: any
}
=>
export interface Route {
path: string
name?: string
hash: string
query: Dictionary<string | (string | null)[]>
params: Dictionary<string>
fullPath: string
matched: RouteRecord[]
redirectedFrom?: string
meta?: any
}
or
export interface Location {
name?: string | null
path?: string
hash?: string
query?: Dictionary<string | (string | null)[] | null | undefined>
params?: Dictionary<string>
append?: boolean
replace?: boolean
}
Metadata
Metadata
Assignees
Labels
No labels