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(typescript): allow objects while creating actions #94

Merged
merged 2 commits into from
Jan 19, 2020

Conversation

jkeam
Copy link
Owner

@jkeam jkeam commented Dec 22, 2019

When creating actions, you can pass in an object literal (DefaultActionTypes). However, the typescript definition incorrectly didn't allow this. This PR addresses that.

This bug was found by @vinipachecov and reported here: #92
And by @sayjeyhi and reported here: #89

@vinipachecov
Copy link

vinipachecov commented Dec 24, 2019

I've made the changes you did in my current version "reduxsauce": "^1.1.1".
current state

But it wasn't enough to fix some of the actions described in the docs:

  • action with default values:
    image
  • custom action:
    image

What I changed to make it work:

  export interface Actions {
    [action: string]: (string[] | DefaultActionTypes | CustomActionType) | null;
  }

  export interface DefaultActionTypes {
    [action: string]: string | null;
  }

 export type CustomActionType = (...a: any) => {[key:string] : any}

I know it is awkward the use of any, but since this is a custom action, it makes sense to me that the function should be able to receive all possible types, and the same would apply to the object returned, but it should be an object in end.

@jkeam
Copy link
Owner Author

jkeam commented Dec 31, 2019

Happy New Years @vinipachecov! Thanks again for your help with this issue. I just updated the PR. Can you give this a go and see if this solves your use case?

@vinipachecov
Copy link

Happy New Years @vinipachecov! Thanks again for your help with this issue. I just updated the PR. Can you give this a go and see if this solves your use case?

I'll give it a try today. I've been working during the new year's eve and during Christmas so until tomorrow I'll reply here.

@vinipachecov
Copy link

Worked fine here @jkeam , I think this is ready to merge :D

@jkeam jkeam merged commit 9a66227 into develop Jan 19, 2020
@jkeam jkeam deleted the bugfix/action-type-definition branch January 19, 2020 02:43
jkeam pushed a commit that referenced this pull request Jan 19, 2020
## [1.1.2](v1.1.1...v1.1.2) (2020-01-19)

### Bug Fixes

* **typescript:** allow objects while creating actions ([#94](#94)) ([9a66227](9a66227))
@jkeam
Copy link
Owner Author

jkeam commented Jan 19, 2020

🎉 This PR is included in version 1.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jkeam jkeam added the released label Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants