From 583444e4b7139c078ad57402ca3e31232282c877 Mon Sep 17 00:00:00 2001 From: mustevenplay Date: Wed, 13 Nov 2024 18:57:18 +0100 Subject: [PATCH 1/3] Add `StoreBundle` type for convenience Adds practical and convenient type when using the `createStore`'s return type externally, without the hassle of implementing it by hand. --- packages/solid/store/src/store.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/solid/store/src/store.ts b/packages/solid/store/src/store.ts index 3402bae1a..2744ce402 100644 --- a/packages/solid/store/src/store.ts +++ b/packages/solid/store/src/store.ts @@ -490,6 +490,8 @@ export interface SetStoreFunction { ): void; } +export type StoreBundle = [get: Store, set: SetStoreFunction]; + /** * Creates a reactive store that can be read through a proxy object and written with a setter function * From 6b63e95213ad7bcef5b5c5d6e255360c5fe5aacf Mon Sep 17 00:00:00 2001 From: mustevenplay Date: Wed, 13 Nov 2024 19:06:26 +0100 Subject: [PATCH 2/3] Replace `createStore`'s return type with its compact version --- packages/solid/store/src/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/solid/store/src/store.ts b/packages/solid/store/src/store.ts index 2744ce402..195aabb1e 100644 --- a/packages/solid/store/src/store.ts +++ b/packages/solid/store/src/store.ts @@ -501,7 +501,7 @@ export function createStore( ...[store, options]: {} extends T ? [store?: T | Store, options?: { name?: string }] : [store: T | Store, options?: { name?: string }] -): [get: Store, set: SetStoreFunction] { +): StoreBundle { const unwrappedStore = unwrap((store || {}) as T); const isArray = Array.isArray(unwrappedStore); if ("_SOLID_DEV_" && typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") From 7fdb766f934bc601f77a0e4091b48d89681b35c4 Mon Sep 17 00:00:00 2001 From: mustevenplay Date: Wed, 13 Nov 2024 19:08:04 +0100 Subject: [PATCH 3/3] Export `StoreBundle` type --- packages/solid/store/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/solid/store/src/index.ts b/packages/solid/store/src/index.ts index 99a3ae076..9a3317567 100644 --- a/packages/solid/store/src/index.ts +++ b/packages/solid/store/src/index.ts @@ -8,6 +8,7 @@ export type { SetStoreFunction, SolidStore, Store, + StoreBundle, StoreNode, StorePathRange, StoreSetter