Vetur: Intellisense for vue function api

Created on 12 Jul 2019  路  3Comments  路  Source: vuejs/vetur

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ

Info

  • Platform: MacOS
  • Vetur version: 0.21.1
  • VS Code version: 1.36.1

Hey, I know that vetur support Intellisense like mentioned here https://vuejs.github.io/vetur/intellisense.html . But it doesn't support for setup yet. Which is used for vue-function-api

Here's the code I tried

<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js + TypeScript App" />
    <div>
      <span>count is {{ count }}</span>
      <span>plusOne is {{ plusOne}}</span>
      <button @click="increment">count++</button>>
    </div>
  </div>
</template>

<script lang="ts">
import Vue from 'vue'
import { value, computed, watch, onMounted } from 'vue-function-api'
import HelloWorld from '@/components/HelloWorld.vue' // @ is an alias to /src

export default Vue.extend({
  setup() {
    const count = value(0)
    const plusOne = computed(() => count.value)

    const increment = () => {
      count.value++
    }

    watch(
      () => count.value * 2,
      val => {
        console.log(`count * 2 is ${val}`)
      }
    )

    onMounted(() => {
      console.log(`mounted`)
    })

    return {
      count,
      plusOne,
      increment
    }
  },
  name: 'home',
  components: {
    HelloWorld
  }
})
</script>

I still don't get the intellisense auto complete for count, plusOne, and increment.

Thanks for developing this extension btw. :)

upstream

Most helpful comment

I guess it's impossible to support vue-function-api because there is no way to extend Vue instance type from plugins. This is known limitation for current Vue's typings. (ref #1226 )
We will be able to support setup and declared properties by it in Vue v3.

All 3 comments

I guess it's impossible to support vue-function-api because there is no way to extend Vue instance type from plugins. This is known limitation for current Vue's typings. (ref #1226 )
We will be able to support setup and declared properties by it in Vue v3.

Hey there 馃憢

Would that be possible to add few JSDoc comments to our component to make it works in the meanwhile?

I think that's an outdated issue.
The new @vue/composition-api is work well for me

Was this page helpful?
0 / 5 - 0 ratings