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

Improve slice action creator types #94

Merged
merged 1 commit into from
Jan 25, 2019
Merged

Improve slice action creator types #94

merged 1 commit into from
Jan 25, 2019

Conversation

denisw
Copy link
Contributor

@denisw denisw commented Jan 24, 2019

Instead of ...args: any[], each action creator now expects the payload inferred from the corresponding case reducer.

Fixes #93.

@netlify
Copy link

netlify bot commented Jan 24, 2019

Deploy preview for redux-starter-kit-docs ready!

Built with commit d3458b1

https://deploy-preview-94--redux-starter-kit-docs.netlify.com

@markerikson
Copy link
Collaborator

@denisw : I'm seeing a TS compilation failure in Travis, and also showing up locally:

src/createSlice.test.ts:38:35 - error TS2345: Argument of type 'Action<any>' is not assignable to parameter of type 'PayloadAction<any, string>'.
38         expect(reducer(undefined, actions.increment())).toEqual(1)
                                     ~~~~~~~~~~~~~~~~~~~
src/createSlice.test.ts:78:33 - error TS2345: Argument of type 'Action<any>' is not assignable to parameter of type 'PayloadAction<any, string>'.
  Property 'payload' is missing in type 'Action<any>' but required in type 'PayloadAction<any, string>'.
78       expect(reducer(undefined, actions.increment())).toEqual(1)
                                   ~~~~~~~~~~~~~~~~~~~
  src/createAction.ts:12:3
    12   payload: P
         ~~~~~~~
    'payload' is declared here.

Instead of `...args: any[]`, each action creator now expects the
payload inferred from the corresponding case reducer.
@denisw
Copy link
Contributor Author

denisw commented Jan 25, 2019

@markerikson Fixed now.

@markerikson markerikson merged commit e178ead into reduxjs:master Jan 25, 2019
@markerikson
Copy link
Collaborator

Great, thanks!

@jerolimov
Copy link
Contributor

This was a great improvement when using the actions. 👍

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.

None yet

3 participants