Typescript route guard vue3中的参数(路由、发件人、下一个)类型

Typescript route guard vue3中的参数(路由、发件人、下一个)类型,typescript,vue.js,vuejs3,Typescript,Vue.js,Vuejs3,我导出一个函数,并将其传递给路由器。在每次导出之前: export default function (route, from, next) { log.debug(route.path) if (!identity.state.authenticated) { log.debug('redirecting to "login" view...') next({ name: 'login' }) } else { next() } }

我导出一个函数,并将其传递给
路由器。在每次导出之前

export default function (route, from, next) {
  log.debug(route.path)

  if (!identity.state.authenticated) {
    log.debug('redirecting to "login" view...')
    next({ name: 'login' })
  } else {
    next()
  }
}
但这会导致3个类型脚本错误:


哪种类型最适合这些人?我可以将它们设置为对象,但是否有一些类型可以从
vue
导入?

路由器。在此之前,每个
都是:

beforeach(guard:NavigationGuardWithThis):()=>void
NavigationGuardWithis
是:

export interface navigationguardWithis{
(
这:T,,
至:RouteLocationNormalized,
发件人:RouteLocationNormalized,
下一步:NavigationGuardNext
):NavigationGuardReturn |承诺
}
因此,您需要从
vue路由器导入以下类型:

  • 我不知道如何导入,但既然如此,在TypeScript中省略返回也是可以接受的

从“vue路由器”导入{RouteLocationNormalized,NavigationGuardNext}
导出默认函数(
至:RouteLocationNormalized,
发件人:RouteLocationNormalized,
下一步:NavigationGuardNext
) {
/*...*/
}
TS7006: Parameter 'route' implicitly has an 'any' type.
TS7006: Parameter 'from' implicitly has an 'any' type.
TS7006: Parameter 'next' implicitly has an 'any' type.