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

Router-store reducer does not compile with --strictFunctionTypes #1344

Closed
rkirov opened this issue Sep 27, 2018 · 3 comments · Fixed by #1385 or TypescriptID/platform#150
Closed

Router-store reducer does not compile with --strictFunctionTypes #1344

rkirov opened this issue Sep 27, 2018 · 3 comments · Fixed by #1385 or TypescriptID/platform#150

Comments

@rkirov
Copy link
Contributor

rkirov commented Sep 27, 2018

Minimal reproduction of the bug/regression with instructions:

The definition of routerReducer is written to accept a subtype of Action.

https://github.com/ngrx/platform/blob/master/modules/router-store/src/reducer.ts#L23

That is not correct as every action runs through every reducer (if I understand ngrx correctly that is still the case). TypeScript with --strictFunctionTypes errors when you write you your reducers with any type different from reducer(state = defaultState, action: Action).

Expected behavior:

Router reducer should be written as:

routerReducer(state = defaultState, action: Action) {
  const routerAction = action as RouterAction; 
}

The unsafe (but benign) type cast should live inside the reducer function.

Other information:

General issue about --strictFunctionTypes - #951.

I would be willing to submit a PR to fix this issue

[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

@timdeschryver
Copy link
Member

You get a 👍 from me.
(And yes you're right, every actions runs through every reducer)

@brandonroberts
Copy link
Member

👍

@alex-okrushko
Copy link
Member

Thanks Rado!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants