@@ -27,6 +27,7 @@ import {
27
27
ComponentOptionsMixin ,
28
28
} from 'vue'
29
29
import {
30
+ isRouteLocation ,
30
31
RouteLocationRaw ,
31
32
VueUseOptions ,
32
33
RouteLocation ,
@@ -36,7 +37,7 @@ import { isSameRouteLocationParams, isSameRouteRecord } from './location'
36
37
import { routerKey , routeLocationKey } from './injectionSymbols'
37
38
import { RouteRecord } from './matcher/types'
38
39
import { NavigationFailure } from './errors'
39
- import { isArray , isBrowser , isObject , noop } from './utils'
40
+ import { isArray , isBrowser , noop } from './utils'
40
41
import { warn } from './warning'
41
42
42
43
export interface RouterLinkOptions {
@@ -95,15 +96,14 @@ export function useLink(props: UseLinkOptions) {
95
96
const router = inject ( routerKey ) !
96
97
const currentRoute = inject ( routeLocationKey ) !
97
98
98
- const isValidTo = ( to : unknown ) => typeof to === 'string' || isObject ( to )
99
99
let hasPrevious = false
100
100
let previousTo : unknown = null
101
101
102
102
const route = computed ( ( ) => {
103
103
const to = unref ( props . to )
104
104
105
105
if ( __DEV__ && ( ! hasPrevious || to !== previousTo ) ) {
106
- if ( ! isValidTo ( to ) ) {
106
+ if ( ! isRouteLocation ( to ) ) {
107
107
if ( hasPrevious ) {
108
108
warn (
109
109
`Invalid value for prop "to" in useLink()\n- to:` ,
@@ -204,7 +204,7 @@ export function useLink(props: UseLinkOptions) {
204
204
linkContextDevtools . route = route . value
205
205
linkContextDevtools . isActive = isActive . value
206
206
linkContextDevtools . isExactActive = isExactActive . value
207
- linkContextDevtools . error = isValidTo ( unref ( props . to ) )
207
+ linkContextDevtools . error = isRouteLocation ( unref ( props . to ) )
208
208
? null
209
209
: 'Invalid "to" value'
210
210
} ,
0 commit comments