fix(signals): add `StateSignal` to the public API
expose StateSignal store type in order to make it easier for 3rd party extensions to wrap signal store APIs, e.g. patchState with immer immutability - generic StateSignal<State> is difficult to obtain via ReturnType<typeof signalStore> or any other way.
no breaking changes
PR Checklist
Please check if your PR fulfills the following requirements:
- [X] The commit message follows our guidelines: https://github.com/ngrx/platform/blob/main/CONTRIBUTING.md#commit
PR Type
What kind of change does this PR introduce?
[X] Refactoring (no functional changes, no api changes)
What is the current behavior?
What is the new behavior?
Does this PR introduce a breaking change?
[ ] Yes
[X] No
Deploy Preview for ngrx-io canceled.
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | c9eecffea7ce475e52b5902a2926d2e175a80c5d |
| Latest deploy log | https://app.netlify.com/sites/ngrx-io/deploys/65cd25453f056e0008e89963 |
I think that one was already on the table: https://github.com/ngrx/platform/issues/4116#issuecomment-1803971396
@rainerhahnekamp not sure if that's the same thing - I don't care about the symbol.
Lacking the type is a blocker when it comes to providing a more specialized patchState. The original one is:
export declare function patchState<State extends object>(stateSignal: StateSignal<State>, ...updaters: Array<Partial<State & {}> | PartialStateUpdater<State & {}>>): void;
I just need to know the StateSignal type for the wrapping function; it's type-only, no effect on runtime whatsoever.
And I can't infer it, as it's generic :( type param gets inferred to object because of:
export type StateSignal<State extends object> = {
...
};
Ah, I see; I remember struggling with that object as well and giving up in the end.
Thanks Tomasz! Btw, public API exports are usually released as features. Since @ngrx/signals is still in the dev preview, I changed the PR type to fix, so it can be released in the patch release too.