Property does not exist on type data

I’m running into the following issue:

I try to pass the results I get from retrieve_data.ts to a property. I successfully get the results, however, when I import the function and I try to pass the values to the property info, I get the this message:

TS2339: Property ‘info’ does not exist on type ‘{ name: string; components: { IonButtons: DefineComponent<IonButtons & InputProps, object, any, Record<string, ComputedGetter | WritableComputedOptions>, … 7 more …, {}>; … 5 more …; IonToolbar: DefineComponent<…>; }; data(): { …; }; created(): void; }’.


import useData from "../data/retrieve_data";

export default {
 name: 'Home',

 . . .

  data(){
    return{
      info: [],
    }
  },

  created(){
      this.info=useData.data();
  },

}

I have tried everything: setup, onMounted, return, clearing the cache, changing the name of the property and functions…nothing has worked out for me. I tried searching in the documentation but I couldn’t find anything useful. I don’t know what’s wrong. I’m new to Ionic and Vue but from what I know, that should be enough but probably I’m missing something but I have no idea what that could be.

Thank you in advance.

Make sure you are using the defineComponent function exported from vue when setting up your component as it provides additional type information that TypeScript needs:

import { defineComponent } from 'vue';

export default defineComponent({
  ...
});
2 Likes

That’s it! Thank you very much.

1 Like

I’m going through the same problem but when I use define component my page doesn’t pop up anymore