Skip to content

fix(router-store): parameterize StoreRouterConfig.serializer by T - #179

Merged
Terrence721 merged 2 commits into
mainfrom
code-review/router-store-router-store-config
Aug 21, 2026
Merged

fix(router-store): parameterize StoreRouterConfig.serializer by T#179
Terrence721 merged 2 commits into
mainfrom
code-review/router-store-router-store-config

Conversation

@Terrence721

Copy link
Copy Markdown
Owner

Closes #178.

Summary

  • StoreRouterConfig<T>.serializer wasn't parameterized by T, even though RouterStateSerializer<T> is generic - provideRouterStore<T>({ serializer: SomeSerializer }) accepted a serializer producing a shape unrelated to T with no compile error. Confirmed with a throwaway type probe before and after the fix.
  • Fixing the field alone broke _createRouterConfig's own default-fill (MinimalRouterStateSerializer doesn't satisfy the interface's default T). Scoped _createRouterConfig's own type to StoreRouterConfig<BaseRouterStoreState> rather than widening the public default T - it's never called with an explicit generic anywhere, so this has no external ripple.
  • Running the real suite with the fix applied surfaced a live instance of the same gap in integration.spec.ts's custom-serializer test, masked because createTestModule() wasn't generic either. Made it generic (spec/utils.ts) and passed the explicit type argument at that one call site.
  • Reviewed out of file order (ahead of reducer.ts/router_selectors.ts) since it was surfaced directly by provide_router_store.ts's review (Code review: modules/router-store/src/provide_router_store.ts #176/docs(router-store): review provide_router_store.ts, no findings #177, merged).

Test plan

  • yarn nx run router-store:build-package - clean
  • yarn nx run router-store:test - 156/156 passing, 1 pre-existing skip, 0 type errors (previously silent on this gap, now genuinely checked)

StoreRouterConfig<T>.serializer accepted any RouterStateSerializer
subclass regardless of whether it actually produced T, since the
field wasn't parameterized even though RouterStateSerializer<T> is
generic. provideRouterStore<T>({ serializer: WrongShapeSerializer })
compiled with no error.

Parameterized the field and widened _createRouterConfig's own
internal binding to BaseRouterStoreState so its default-fill logic
(which assigns MinimalRouterStateSerializer regardless of the
caller's T) keeps compiling - it's only ever called as a bare DI
factory reference, never with an explicit generic, so this has no
external ripple.

Surfaced a live instance of the same gap in integration.spec.ts's
custom-serializer test, masked by createTestModule() not being
generic either - fixed by making it generic to match.
@Terrence721
Terrence721 merged commit 9071b25 into main Aug 21, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code review: modules/router-store/src/router_store_config.ts

1 participant