-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make createActionCreator simpler by removing resolve
callback from executor
#122
Comments
@LouizFC @Haaxor1689 @rlesniak can we have you guys here? |
I created a codesandbox as a demo for the proposed API. |
I clicked "close issue" button by mistake. :D |
resolve
callback from executor argumentresolve
callback from executor argument
resolve
callback from executor argumentresolve
callback from executor
@thebrodmann I think that the current API is fine and removes the boilerplate of setting But also I am not agains't it. The only "resistance" I have on this change is by my experience with #106 . I found very difficult to extract and modify return types correctly, but if you get it right I have no objections. Edit: Also, backwards compatibility |
The only thing can be returned by callable is an object by
Yeah, unfortunately, this is not backward compatible but I think it makes the
Ah, thank you for that, It's. This playground can show the proposed API. |
Also in this playground the extra properties are not allowed. |
The proposed API looks fine, my only nitpick is: If you try to preview the arguments both on playground or IDE, the arguments for the function will show up as As I expressed earlier, I think we should not mess with |
Actually it should work! Is your TypeScript version above 3.0?
Maybe we can be backward compatible. I will try to create a backward-compatible playground soon. |
Hey @thebrodmann !
The error message caused by specifying extra properties feel strange. I think it is better to change return value type of from: callable?: (...args: TArguments) => TReturn & (Exclude<keyof TReturn, keyof TypelessAction> extends never ? TReturn : "{ payload?: any, meta?: any }" to: callable?: (...args: TArguments) => TReturn & (Exclude<keyof TReturn, keyof TypelessAction> extends never ? TReturn : never) What do you think about this? |
What makes you think so? |
The ideal error and error message are as follows. error: error message: The ideal return value type of However, |
|
|
I think this error message is more descriptive than the former one. BTW, I can't make a decision on it in this way. So let's vote on it. Please add a 👍 on the error message that you think is better. |
@LouizFC |
From TypeScript 3.0 we are able to infer function's parameters with their names. So now we can remove
resolve
callback fromexecutor
increateActionCreator
to make the API simpler.Example:
There is one caveat point that has been encountered in #108 and that's
type
property in return type of callable (2nd argument of proposedcreateActionCreator
). One possible solution for the mentioned problem which I think is ideal is to set the type oftype
property toundefiend
.We can call the callable's return type
TypelessAction
as it's type should be undefined.The text was updated successfully, but these errors were encountered: