Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntelliSense not working for context.root.$router in the Vue compositionAPI #1926

Closed
3 tasks done
DarkLite1 opened this issue May 20, 2020 · 5 comments
Closed
3 tasks done

Comments

@DarkLite1
Copy link

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Windows Server 206
  • Vetur version: 0.24
  • VS Code version: 1.45.1 stable

Problem

IntelliSense for the context object of the new composition API is not working correctly.

The following SFC works perfectly fine and redirects the user upon authentication to the home page:

<template>
  <q-page padding>
    <h3>Login</h3>
    <h5>Hi there stranger. Would you mind telling us who you are?</h5>
    <p>Click on the login button on the to right corner</p>
  </q-page>
</template>

<script lang="ts">
import { defineComponent, onBeforeMount } from '@vue/composition-api'
import { useAccount } from '../../src/comp-functions/useAccount'

export default defineComponent({
  setup(props, context) {
    const { isAuthenticated } = useAccount()
    onBeforeMount(() => {
      if (isAuthenticated.value) {
        context.root.$router.push('/')
      }
    })
  },
})
</script>

TypeScript is not reporting any error but Vetur is showing a red squiggly line under the word $router and IntelliSense can't complete it. Although the code works fine:

image

Also no error in the Vue Language Server:
image

Reproducible Case

Full source code can be found here.

@yoyo930021
Copy link
Member

If you install vue-router package?

@DarkLite1
Copy link
Author

DarkLite1 commented Jun 3, 2020

The functionality is fine, everything works as expected. However, when having multiple projects open at the same time in vs code than Vetur fails to resolve the context.root.$router and shows a squiggly line. When working in vscode with only this project open it works fine and Vetur doesn't report an issue.

@yoyo930021
Copy link
Member

#424

@octref
Copy link
Member

octref commented Jun 8, 2020

Closing as duplicate of #424.

@octref octref closed this as completed Jun 8, 2020
@IlCallo
Copy link

IlCallo commented Jun 17, 2020

Experiencing the same behaviour since today, totally random 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants