I’m using Pinia for state management in my Vue.js application, and I’ve encountered an issue where Set object methods are not accessible within actions. My state is defined as follows:
state: () => {
return {
user: null as User,
abilities: new Set([] as string[]),
}
},
In my actions, I have a method that checks if a user has a specific ability. However, when I try to use the has method of the Set object, it throws an error saying “has is not a function.” Here’s the action method:
allows(ability: string) {
if (!this.user) {
return false;
}
return this.abilities.has(ability);
},
From my observation, the abilities property seems proxied, preventing direct access to the Set methods. How can I access the Set methods in this context? Is there a specific way to handle Set objects in Pinia, or am I missing how I should structure my store?
Any insights or solutions would be greatly appreciated!