fix(types): properly type HomeHeroContext in AppNavBar

TypeScript error: Context type was incorrectly inferred when using
fallback React.createContext(null), causing type mismatch.

Solution: Add explicit HomeHeroContextValue type and cast both the
dynamically loaded context and the fallback to this type.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-20 13:01:50 -05:00
parent ae7463d917
commit f9a7cb7f05

View File

@@ -15,6 +15,11 @@ import { AbacusDisplayDropdown } from './AbacusDisplayDropdown'
// Import HomeHeroContext for optional usage
import type { Subtitle } from '../data/abaciOneSubtitles'
type HomeHeroContextValue = {
subtitle: Subtitle
isHeroVisible: boolean
} | null
// HomeHeroContext - imported dynamically to avoid circular deps
let HomeHeroContextModule: any = null
try {
@@ -23,10 +28,11 @@ try {
// Context not available
}
const HomeHeroContext = HomeHeroContextModule?.HomeHeroContext || React.createContext(null)
const HomeHeroContext: React.Context<HomeHeroContextValue> =
HomeHeroContextModule?.HomeHeroContext || React.createContext<HomeHeroContextValue>(null)
// Use HomeHeroContext without requiring it
function useOptionalHomeHero(): { subtitle: Subtitle; isHeroVisible: boolean } | null {
function useOptionalHomeHero(): HomeHeroContextValue {
return useContext(HomeHeroContext)
}