Skip to content

Add StoreBundle<T> type#2363

Merged
ryansolid merged 4 commits into
solidjs:mainfrom
mustevenplay:patch-1
May 14, 2026
Merged

Add StoreBundle<T> type#2363
ryansolid merged 4 commits into
solidjs:mainfrom
mustevenplay:patch-1

Conversation

@mustevenplay
Copy link
Copy Markdown
Contributor

@mustevenplay mustevenplay commented Nov 13, 2024

Summary

Here I added StoreBundle<T>; a useful type extracted directly from the createStore function's return type:
type StoreBundle<T> = [get: Store<T>, set: SetStoreFunction<T>]

How did you test this change?

This type is identical to the return type of the createStore function, so nothing really should change, besides the fact that it's definitely more portable, more compact, and depending on who we ask, more readable.
All tests have been successfully ran, though.

Adds practical and convenient type when using the `createStore`'s return type externally, without the hassle of implementing it by hand.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 13, 2024

🦋 Changeset detected

Latest commit: bcc0d5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
solid-js Patch
test-integration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ryansolid
Copy link
Copy Markdown
Member

This seems reasonable.. just thinking about naming.. Do the other Signal accessor pair have a name? Maybe consistent naming won't be possible until 2.0. Would love someone who looks at the TS conventions of this repo take a look.

@mustevenplay
Copy link
Copy Markdown
Contributor Author

The current return type of createSignal is Signal<T>, which is alias to [get: Accessor<T>, set: Setter<T>]. In my opinion, the chosen names Accessor and Setter might be kind of ambiguous, to which I suggest we might want to try coming up with a convention that could unify return types of functions like createSignal or createStore with a naming such as "FooBundle" (like in this case, StoreBundle). Keeping the current naming could be a good idea too, but I could as well suggest to give it a specific name for each return type.
These conventions applied on the current Signal<T> type would look like this:

type SignalBundle<T> = [get: SignalAccessor<T>, set: SignalSetter<T>]

@ryansolid ryansolid merged commit 02b6291 into solidjs:main May 14, 2026
@ryansolid
Copy link
Copy Markdown
Member

ryansolid commented May 14, 2026

Thanks. I'm going with StoreReturn. But I've merged it as the base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants