fix: keep navigation theme type when adapting a single theme - #5136
Open
huytdps13400 wants to merge 1 commit into
Open
huytdps13400 wants to merge 1 commit into
huytdps13400 wants to merge 1 commit into
Conversation
The light-only and dark-only overloads of adaptNavigationTheme returned the narrow NavigationTheme type, dropping `fonts` and custom colors from the input theme even though they are preserved at runtime. This made the result unassignable to React Navigation's Theme. Return the input theme type, as the overload for both themes already does. Fixes callstack#4751 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Found potential problems with the pull request:
|
This branch has not been deployed
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.
Motivation
adaptNavigationThemecalled with onlyreactNavigationLight(or onlyreactNavigationDark) is typed to return the narrowNavigationTheme, sofontsand any extra colors of the passed theme are lost at the type level, even though they are preserved at runtime. The result can't be passed toNavigationContainer:Root cause: the two single-theme overloads declare
LightTheme: NavigationTheme/DarkTheme: NavigationTheme, while the overload taking both themes already returns the generic input types (TLight/TDark). This PR makes the single-theme overloads returnTas well. It's a type-only change; runtime behavior is unchanged.T extends NavigationTheme, so existing code that expectsNavigationThemekeeps compiling.Related issue
Fixes #4751
Screenshots / Videos
N/A (types only)
Test plan
should keep fonts and custom colors when adapting a single themetosrc/core/__tests__/theming.test.tsx. It readsfontsand a custom color from the result of a light-only and a dark-only call.yarn typecheckfails withTS2339: Property 'fonts' does not exist on type 'NavigationTheme'(and the same forcolors.secondary).yarn typecheckpasses.const t: Theme = adaptNavigationTheme({ reactNavigationLight: DefaultTheme }).LightTheme(from@react-navigation/native). It fails with the TS2741 error above onmainand compiles with this change.yarn typecheck,yarn lint(changed files) andyarn testall pass (54 suites, 693 tests).Platforms affected: all (TypeScript types only).
This fix was prepared with AI assistance (Claude Code) and verified locally with the tests above.
🤖 Generated with Claude Code