From d2a4defc381ae8e023b45b05e4ac8588fe2add9e Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 24 Jan 2023 09:10:46 +0100 Subject: [PATCH] fix: avoid spread operator even in devtools code See #1885 --- packages/pinia/src/devtools/plugin.ts | 9 +++++---- packages/pinia/src/store.ts | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/pinia/src/devtools/plugin.ts b/packages/pinia/src/devtools/plugin.ts index b921f5ac..83b32f53 100644 --- a/packages/pinia/src/devtools/plugin.ts +++ b/packages/pinia/src/devtools/plugin.ts @@ -35,6 +35,7 @@ const componentStateTypes: string[] = [] const MUTATIONS_LAYER_ID = 'pinia:mutations' const INSPECTOR_ID = 'pinia' +const { assign } = Object /** * Gets the displayed name of a store in devtools @@ -420,10 +421,10 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) { const eventData: TimelineEvent = { time: now(), title: formatMutationType(type), - data: { - store: formatDisplay(store.$id), - ...formatEventData(events), - }, + data: assign( + { store: formatDisplay(store.$id) }, + formatEventData(events) + ), groupId: activeAction, } diff --git a/packages/pinia/src/store.ts b/packages/pinia/src/store.ts index e4be1beb..80e6ee24 100644 --- a/packages/pinia/src/store.ts +++ b/packages/pinia/src/store.ts @@ -674,10 +674,11 @@ function createSetupStore< // avoid listing internal properties in devtools ;(['_p', '_hmrPayload', '_getters', '_customProperties'] as const).forEach( (p) => { - Object.defineProperty(store, p, { - value: store[p], - ...nonEnumerable, - }) + Object.defineProperty( + store, + p, + assign({ value: store[p] }, nonEnumerable) + ) } ) } -- 2.47.2