0

When I use Pinia in my Nuxt3 project:

const {isSomeFlag} = storeToRefs(someStore);

I see this type of isSomeFlag

isSomeFlag: Ref<{
    value: boolean
    [RefSymbol]: true
}>

instead

isSomeFlag: Ref<boolean>

Same problem is with arrays and objects and I have TS errors when I unref these Refs. But code is working correctly - only TS errors.

How to fix it?

"vue": "3.4.15", "nuxt": "3.8.1", "@pinia/nuxt": "^0.5.1", "pinia": "^2.1.7",

I have tried to use properties of store directly

const isSomeFlag = someStore.isSomeFlag;

and it has type:

isSomeFlag: {
    value: boolean;
    [RefSymbol]: true;
}

But it is not reactive

I have tested storeToRefs on clear project (Vue3 + Pinia): it is correct Ref type enter image description here

2
  • What is the error? If you see it in IDE only but the code works as intended, this should be considered IDE problem, unless proven otherwise. someStore is not shown. The only possibility for "and it has type" would be that it's declared incorrectly Commented May 20, 2024 at 15:42
  • It seems OK here, T = Ref<string> Commented May 20, 2024 at 16:49

1 Answer 1

0

It was vue-demi package

I have removed this from tsconfig and incorrect types went away.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.