Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(signals): provide ability to use interface as state type #4133

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

markostanimirovic
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #4117

What is the new behavior?

We can use interfaces as state/nested slice types:

interface User {
  id: number;
  name: string;
}

interface State {
  user: User;
}

const state = signalState<State>({
  user: { id: 1, name: 'Marko' },
});

state.user // type: DeepSignal<User>
state.user.name // type: Signal<string>

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Copy link

netlify bot commented Nov 15, 2023

Deploy Preview for ngrx-io canceled.

Name Link
🔨 Latest commit b6cd779
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/65577dcd978b56000849d395

@markostanimirovic markostanimirovic force-pushed the feat/signals/interface-as-state-type branch from 0091e57 to 463470e Compare November 15, 2023 09:43
Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before approving/merging, do we want to update the records to objects first?

@brandonroberts brandonroberts merged commit 9c8304a into main Nov 19, 2023
5 checks passed
@brandonroberts brandonroberts deleted the feat/signals/interface-as-state-type branch November 19, 2023 02:55
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.

[Signal Store] Using an interface for the state type causes a typing issue
3 participants