]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor(types): fix type error
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 21 Jun 2021 08:55:07 +0000 (10:55 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 21 Jun 2021 08:55:22 +0000 (10:55 +0200)
Close #1007

src/RouterLink.ts

index 6be888bcd2c5e6c545cebc28d26a2ff271568ca7..fdce3d1f8c2ef5686ef6f66fe6454e032eec446a 100644 (file)
@@ -136,25 +136,26 @@ export function useLink(props: UseLinkOptions) {
   // devtools only
   if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && isBrowser) {
     const instance = getCurrentInstance()
-    if (!instance) return
-    const linkContextDevtools: UseLinkDevtoolsContext = {
-      route: route.value,
-      isActive: isActive.value,
-      isExactActive: isExactActive.value,
-    }
+    if (instance) {
+      const linkContextDevtools: UseLinkDevtoolsContext = {
+        route: route.value,
+        isActive: isActive.value,
+        isExactActive: isExactActive.value,
+      }
 
-    // @ts-expect-error: this is internal
-    instance.__vrl_devtools = instance.__vrl_devtools || []
-    // @ts-expect-error: this is internal
-    instance.__vrl_devtools.push(linkContextDevtools)
-    watchEffect(
-      () => {
-        linkContextDevtools.route = route.value
-        linkContextDevtools.isActive = isActive.value
-        linkContextDevtools.isExactActive = isExactActive.value
-      },
-      { flush: 'post' }
-    )
+      // @ts-expect-error: this is internal
+      instance.__vrl_devtools = instance.__vrl_devtools || []
+      // @ts-expect-error: this is internal
+      instance.__vrl_devtools.push(linkContextDevtools)
+      watchEffect(
+        () => {
+          linkContextDevtools.route = route.value
+          linkContextDevtools.isActive = isActive.value
+          linkContextDevtools.isExactActive = isExactActive.value
+        },
+        { flush: 'post' }
+      )
+    }
   }
 
   return {