Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
useMyStore()
expect(warnTextCheckPlainObject('poInit')).toHaveBeenWarnedTimes(0)
})
+
+ it('warns when state name conflicts with getters name (with id as first argument)', () => {
+ const useStore = defineStore('main', {
+ state: () => ({ anyName: 0 }),
+ getters: { anyName: (state) => state.anyName },
+ })
+ useStore()
+
+ expect(
+ `[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "anyName" in store "main".`
+ ).toHaveBeenWarnedTimes(1)
+ })
})
localState,
actions,
Object.keys(getters || {}).reduce((computedGetters, name) => {
+ if (__DEV__ && name in localState) {
+ console.warn(
+ `[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`
+ )
+ }
+
computedGetters[name] = markRaw(
computed(() => {
setActivePinia(pinia)