Skip to content

Commit d7a5272

Browse files
📝 Add docstrings to fix-issue-1247-expose-store-options-in-custom-properties
Docstrings generation was requested by @doubledare704. * #3042 (comment) The following files were modified: * `packages/pinia/src/store.ts`
1 parent 57bec95 commit d7a5272

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎packages/pinia/src/store.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,22 @@ function createOptionsStore<
213213
return store as any
214214
}
215215

216+
/**
217+
* Create and register a Pinia store implemented with the setup API (core factory).
218+
*
219+
* Builds the reactive store instance, wires its state into the global Pinia state tree,
220+
* wraps actions for $onAction tracking, attaches $patch/$reset/$subscribe/$dispose helpers,
221+
* applies plugins and devtools metadata, and registers the store on the provided Pinia
222+
* instance. Also prepares Hot Module Replacement (HMR) support and optional hydration logic.
223+
*
224+
* @param $id - Unique store id used as the key in pinia.state and for registration.
225+
* @param setup - Store setup function that receives setup helpers and returns state, getters, and actions.
226+
* @param options - Optional store definition/options; used for plugins, getters (options API compatibility), and hydration.
227+
* @param pinia - The Pinia root instance where the store will be registered.
228+
* @param hot - When true, build the store in hot-update mode (uses a temporary hotState and enables HMR-specific wiring).
229+
* @param isOptionsStore - Set to true for stores created from the Options API so certain setup-store behaviors (like state wiring) are skipped.
230+
* @returns The reactive Store instance exposing state, getters, actions and Pinia helpers.
231+
*/
216232
function createSetupStore<
217233
Id extends string,
218234
SS extends Record<any, unknown>,
@@ -474,12 +490,18 @@ function createSetupStore<
474490
{
475491
_hmrPayload,
476492
_customProperties: markRaw(new Set<string>()), // devtools custom properties
493+
_options: optionsForPlugin, // store options for plugins
477494
},
478495
partialStore
479496
// must be added later
480497
// setupStore
481498
)
482-
: partialStore
499+
: assign(
500+
{
501+
_options: optionsForPlugin, // store options for plugins
502+
},
503+
partialStore
504+
)
483505
) as unknown as Store<Id, S, G, A>
484506

485507
// store the partial store now so the setup of stores can instantiate each other before they are finished without

0 commit comments

Comments
 (0)