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

fix(store): support using createActionGroup with props typed as unions #3713

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?

[x] Bugfix
[ ] 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 #3712

What is the new behavior?

We are able to use the createActionGroup function with props typed as unions:

const booksApiActions = createActionGroup({
  source: 'Books API',
  events: {
    'Load Books Success': props<{ books: string[]; status: 'success' } | { books: Book[] }>(),
  },
});

// works as intended
booksApiActions.loadBooksSuccess({ books: [''], status: 'success' });
booksApiActions.loadBooksSuccess({ books: [{ id: 1, title: '' }] });

Does this PR introduce a breaking change?

[ ] Yes
[x] No

@netlify
Copy link

netlify bot commented Dec 17, 2022

Deploy Preview for ngrx-io ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 153c42f
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/639dc770c3e607000917acc9
😎 Deploy Preview https://deploy-preview-3713--ngrx-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@brandonroberts brandonroberts merged commit e75fa1a into ngrx:master Dec 17, 2022
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.

createActionGroup doesn't handle discriminated union types correctly
3 participants