Skip to content

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

@rkirov

Description

@rkirov

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions