From: Eduardo San Martin Morote Date: Tue, 1 Jun 2021 13:40:14 +0000 (+0200) Subject: refactor: better types X-Git-Tag: v2.0.0-beta.1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46cd6306b5405ebef3eb63eb2c60eb5edb2faba5;p=thirdparty%2Fvuejs%2Fpinia.git refactor: better types --- diff --git a/src/store.ts b/src/store.ts index aa19b71e..63b91f9d 100644 --- a/src/store.ts +++ b/src/store.ts @@ -11,6 +11,7 @@ import { DebuggerEvent, WatchOptions, UnwrapRef, + markRaw, } from 'vue' import { StateTree, @@ -114,14 +115,16 @@ function initStore< // const state: Ref = toRef(_p.state.value, $id) let isListening = true - let subscriptions: SubscriptionCallback[] = [] - let actionSubscriptions: StoreOnActionListener[] = [] + let subscriptions: SubscriptionCallback[] = markRaw([]) + let actionSubscriptions: StoreOnActionListener[] = markRaw([]) let debuggerEvents: DebuggerEvent[] | DebuggerEvent - function $patch(stateMutation: (state: S) => void): void - function $patch(partialState: DeepPartial): void + function $patch(stateMutation: (state: UnwrapRef) => void): void + function $patch(partialState: DeepPartial>): void function $patch( - partialStateOrMutator: DeepPartial | ((state: S) => void) + partialStateOrMutator: + | DeepPartial> + | ((state: UnwrapRef) => void) ): void { let subscriptionMutation: SubscriptionCallbackMutation isListening = false @@ -131,7 +134,7 @@ function initStore< debuggerEvents = [] } if (typeof partialStateOrMutator === 'function') { - partialStateOrMutator(pinia.state.value[$id]) + partialStateOrMutator(pinia.state.value[$id] as UnwrapRef) subscriptionMutation = { type: MutationType.patchFunction, storeName: $id, @@ -361,7 +364,7 @@ function buildStoreToUse< // add getters for devtools if (__DEV__ && IS_CLIENT) { - store._getters = Object.keys(getters) + store._getters = markRaw(Object.keys(getters)) } // apply all plugins