Skip to content
Discussion options

You must be logged in to vote

You can do if ('companyId' in route.params). You can implement this in a custom routeHasParam() function:

import type { RouteLocationNormalizedLoaded } from 'vue-router'

function routeHasParam<
  Route extends RouteLocationNormalizedLoaded,
  Param extends keyof Exclude<Route['params'], Record<PropertyKey, never>>,
>(
  route: Route,
  key: Param
): route is Exclude<Route, { params: Record<PropertyKey, never> }> & {
  params: Record<Param, unknown>
} {
  return key in route.params
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants