-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Update Signature of Actions and Actions#ofType to infer action interface in Effects #860
Comments
I don't know how much effort it will cost or if it's even possible. |
I have something ready at tdeschryver/platform/oftype, without the compat module for now. |
This features is on the critical path for turning on --strictFunctionTypes in google's TS codebase, so I am very invested in getting a solution checked in ASAP. Here is the problem. Currently the following code compiles without an error: this.actions.pipe(
ofType(ActionTypes.CREATE),
mergeMap(
(action: CreatetAction) => {...} How it actually works is that after It appears there are 3 different solutions for better typing 'oftype' floating around - @MikeRyanDev, @tdeschryver and by @mtaran-google. They are slightly different in terms of naming and maybe support for multiple arguments, but for my purposes I think any of them will fix the majority of the failures we are seeing. I want to get ball rolling, so who will create an actual PR for this, so that we can start reviewing it? |
The version I came up with is at https://gist.github.com/mtaran-google/8f30d4853e225e830d9a3e712eb96618 Blame clang-format for the indentation. |
@rkirov Hey Rado, Does this patch passes Google tests? (I haven't tried - not sure if you ran those). |
I did an internal test and there is just a single failure (though it only tests pipable ofType). |
Using the new mapped types feature in TypeScript 2.8 we can now write a type safe version of
Actions#ofType
that can correctly infer the interface of the action based on the provided action type:This will be a major breaking change for Effects. To minimize the impact we should add an
@ngrx/effects/compat
submodule that exports a backwards compatible version ofActions
andofType
so that developers can incrementally upgrade. We will remove@ngrx/effects/compat
in 7.0.The text was updated successfully, but these errors were encountered: