fix(router-store): parameterize StoreRouterConfig.serializer by T - #179
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #178.
Summary
StoreRouterConfig<T>.serializerwasn't parameterized byT, even thoughRouterStateSerializer<T>is generic -provideRouterStore<T>({ serializer: SomeSerializer })accepted a serializer producing a shape unrelated toTwith no compile error. Confirmed with a throwaway type probe before and after the fix._createRouterConfig's own default-fill (MinimalRouterStateSerializerdoesn't satisfy the interface's defaultT). Scoped_createRouterConfig's own type toStoreRouterConfig<BaseRouterStoreState>rather than widening the public defaultT- it's never called with an explicit generic anywhere, so this has no external ripple.integration.spec.ts's custom-serializer test, masked becausecreateTestModule()wasn't generic either. Made it generic (spec/utils.ts) and passed the explicit type argument at that one call site.reducer.ts/router_selectors.ts) since it was surfaced directly byprovide_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- cleanyarn nx run router-store:test- 156/156 passing, 1 pre-existing skip, 0 type errors (previously silent on this gap, now genuinely checked)