You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replacing the built in serializer with a custom one results in a type warning, when using a selector in the StoreRouterConfig:
interfaceMyRouterStateextendsBaseRouterStoreState{customParam: any;}classMyRouterStateSerializerextendsRouterStateSerializer<MyRouterState>{// ...}constselectRouter: Selector<any,RouterReducerState<MyRouterState>>=// ...;// in the Module:StoreRouterConnectingModule.forRoot({stateKey: selectRouter,serializer: MyRouterStateSerializer})
results in the warning:
TS2322:
Type 'MemoizedSelector<object, RouterReducerState<MyRouterState>>' is not assignable to type 'StateKeyOrSelector'.
Type 'MemoizedSelector<object, RouterReducerState<MyRouterState>>' is not assignable to type 'Selector<any, RouterReducerState<SerializedRouterStateSnapshot>>'.
Type 'RouterReducerState<MyRouterState>' is not assignable to type 'RouterReducerState<SerializedRouterStateSnapshot>'.
Types of property 'state' are incompatible.
Type 'MyRouterState' is not assignable to type 'SerializedRouterStateSnapshot'.
Property 'root' is missing in type 'MyRouterState'.
The proposed change would be to use generics on StateKeyOrSelector and StoreRouterConfig:
Describe any alternatives/workarounds you're currently using
Currently, the only way to prevent this issue is not typing the selector correctly (which is bad imo), or suppressing the warning with @ts-ignore (which is also not great, since it makes me wonder whether the root property of SerializedRouterStateSnapshot is necessary or not)
Replacing the built in serializer with a custom one results in a type warning, when using a selector in the StoreRouterConfig:
results in the warning:
The proposed change would be to use generics on
StateKeyOrSelector
andStoreRouterConfig
:Describe any alternatives/workarounds you're currently using
Currently, the only way to prevent this issue is not typing the selector correctly (which is bad imo), or suppressing the warning with
@ts-ignore
(which is also not great, since it makes me wonder whether theroot
property ofSerializedRouterStateSnapshot
is necessary or not)Other information:
Demo on StackBlitz
If accepted, I would be willing to submit a PR for this feature
[ ] Yes (Assistance is provided if you need help submitting a pull request)
[x] No
The text was updated successfully, but these errors were encountered: