-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Type assertion on the whole action #19
Comments
Hello @farzadmf type CameraAction = ReturnType<typeof cameraActions.getCamerasSuccess>;
const receiveCameras = (state: CameraState, action: CameraAction) => {
... I will open issue today for discussion/feedback on the API 2.0, new features like Symbols support, but also improvements to createAction (got rid of duplicated type argument finally :)) and probably push the working implementation to the next branch for testing. EDIT: API v2.0 discussion here: #22 |
Hello @piotrwitek thank you for your answer, So how I can I keep track of the new API version you mentioned and when it will available? |
2 days top I think, I'm heavily working on it |
Looking forward to start using ReturnType. Can I just update TS to 2.8@rc and start using ReturnType with typesafe-actions? |
@dziamid I have done so with success. I have a saga that looks like this: import { sessionActions as SA } from './actions'
function* setToken(action: ReturnType<typeof SA.setToken>) { } Where |
@duro, sweet, was looking for the exact same use case. Are you using the version 1 of this library? |
Yes. I too am eager to see v2. I've been playing with TS2.8 and I can
totally see how it's going to make this library better.
…On Thu, Mar 22, 2018 at 1:08 AM Dziamid ***@***.***> wrote:
@duro <https://github.com/duro>, sweet, was looking for the exact same
use case. Are you using the version 1 of this library?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABE4Ex-60V1UJtIGOsetAgtayx8sAJbks5tg1wGgaJpZM4SlU3y>
.
|
How exactly? Type and payload assertions are all I care about right now. |
Hi @dziamid, for example this: #21 (comment) |
Closing as issue seems to be unactionable. |
Hi,
I just found out about your library, and I think it is what I have been looking for to substantially reduce boilerplate code for actions and action creators; thank you!
Creating actions (using
createAction
) andswitch
ing on them (usinggetType
) in the reducer works fine, but I was wondering if there's a way to do type checking for a method that expects a specific kind of action.Example of my actions (I'm using lodash for
values
andmap
):Maybe a good example would be a case where the reducer wants to call another method for a specific action type, for example, in my reducer:
Now, in my
receiveCameras
method, I want to make sure the second argument is of typecameraActions.getCamerasSuccess
.I can do something like this:
I was wondering if I can specify the type when defining the parameter in the method to avoid doing that
if
checkThank you
The text was updated successfully, but these errors were encountered: