-
Notifications
You must be signed in to change notification settings - Fork 9
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
Issue with void Param after Typescript 3.4 #14
Comments
@jasonvasquez this is a known problem with how the typings of typescript-fsa work with a feature for this project that allows optional parameters. I've offered some insight upstream, but there's been little to no activity (aikoven/typescript-fsa#56). For this, there's a couple of different solutions for what to change on the doThing thunk:
const doThing = createAsyncAction("DO_THING",
async () => {
return 1;
},
);
const doThing = createAsyncAction<{}, number>("DO_THING",
async () => {
return 1;
},
); Let me know if this works for you |
Alright, cool - thanks! |
@xdave in TypeScript 3.6 use createAsync<unknown, number>("example") |
I just implemented a fix for the return type, I could probably do the same for the params... |
Maybe this is the right way const doThing = createAsyncAction("DO_THING",
async (): Promise<number> => {
return 1;
},
); |
Perhaps. New eslint seems to like to enforce doing that. |
Hello,
I've been using typescript-fsa-redux-thunk combined with typescript-fsa-reducers for quite some time now very happily - thankyou!
Today, I upgraded several of my projects to Typescript 3.4, at which point many of my thunk-based actions suddenly were not working properly in my reducers. Specifically, I have simple async actions defined somewhat like:
with reducers structured like:
This worked fine in the past, I was able to use them simply in calls like
dispatch(doThing.action())
, reducers worked as expected.Today, I can define the actions fine, but in the reducers, I receive this typescript compilation error:
It looks like it is due to this rule in typescript-fsa:
Basically,
Params extends void
fires here, meaning params should be defined asparams?
, but I think they're being passed in asparams: void
.I hope I interpreted that issue correctly. If I have a type other than void for the thunk param, then everything compiles fine. This code worked prior to Typescript 3.4, so I'm presuming a more thorough type checking has occurred here to catch this particular one.
Relevant packages:
Let me know if I can provide any other details!
The text was updated successfully, but these errors were encountered: