Vue3 Computed Props

Posted on  by admin
Modified1 year, 2 months ago.

I have a Vue3 project with TypeScript, and I'm finding I cannot access the properties (using dot notation or named indexing) of the returned JS object from one computed property in another computed property. So given the code below, my TS compiler will have a compilation error trying to read friends on the this.user object.

This makes sense as this.user is a function, but in the Vue world it's treated as a property. And the code will work fine if the lang="ts" part is removed.

Here is the error:. I created this sample code with the Vue cli (vue create).

I'm not sure if this is even a problem with TypeScript or Vue?

I don't want to remove the TypeScript tag for this code, but might be the best option. not sure what your user computed is supposed to do as it has no reactive source?

James Skemp
7,656