vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.83k stars 395 forks source link

Props not recognized by intellisense (options API) #3888

Closed mauromascarenhas closed 8 months ago

mauromascarenhas commented 8 months ago

Issue

As the title states, props are not being recognized by intellisense in options API (data and computed are still working as expected). Thus, no suggestion or type inference is made.

Screenshots

Prop being treated as "any"

Screenshot showing that the "id" prop is being treated as type "any"

Prop is not recognized/recommended by intellisense

Screenshot showing that the "id" prop is not being recognized by the intellisense

Prop is part of "this"

Screenshot showing that the "id" prop is being recognized as owned by the current object instance

Steps to reproduce

By using the following code (used About view from project initialization as a base), it is possible to notice that the id prop is not recognized (link to playground):


<template>
  <div class="about">
    <h1>This is an about page</h1>
    <div>A simple test text: {{ textTestSample }}</div>
    <div>A simple test number: {{ idPlusOne }}</div>
  </div>
</template>

<script>
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  data(){
    return {
      dataTest: ""
    };
  },
  computed: {
    idPlusOne(){ return this.id + 1; },
    textTestSample(){ return this.dataTest + " - sample"; }
  },
  methods: {
    log(){
      console.log(this.id, this.dataTest);
    }
  }
});
</script>

<style>
@media (min-width: 1024px) {
  .about {
    min-height: 100vh;
    display: flex;
    align-items: center;
  }
}
</style>

Environment

so1ve commented 8 months ago

Seemed to be a vue core issue. https://github.com/vuejs/core/issues/9296