angularngrxngrx-router-store

Issue with NgRx Custom Serializer - type error


I'm trying to implement ngx-router-store with a custom serializer - using the code shown in their docs here, but I am getting the following error:

ERROR in src/app/app.module.ts(58,13): error TS2345: Argument of type '{ serializer: typeof CustomSerializer; }' is not assignable to parameter of type 'StoreRouterConfig | StoreRouterConfigFunction'.
  Object literal may only specify known properties, and 'serializer' does not exist in type 'StoreRouterConfig | StoreRouterConfigFunction'.

app.module.ts

imports: [
    StoreModule.forRoot(reducers, { metaReducers }),
        RouterModule.forRoot([
            // routes
        ]),
        StoreRouterConnectingModule.forRoot({
            serializer: CustomSerializer,
        }),
        .......
       ]

reducers/index.ts

export const reducers: ActionReducerMap<AppState> = {
    router: routerReducer
};

I'm using router-store version 7.1.0:

enter image description here

The only property the config object in StoreRouterConnectingModule.forRoot accepts is stateKey. Looking at the forRoot method of StoreRouterConnectingModule the types expected are StoreRouterConfig | StoreRouterConfigFunction as detailed in the error.

I'm unsure as to whether I have done something wrong, there's something I haven't implemented or if perhaps there is a version difference with the docs.


Solution

  • Could you try cleaning the node_modules folder and do new install? Also make sure all of the deps are v7.

    I just tried the config from in the docs and it's working here.