Skip to content

ThemeContext.colors JSDoc says "current theme" but returns all themes #187

@hadarziv-army

Description

@hadarziv-army

Hey 👋🏻

The docs and JSDoc for ThemeContext.colors describe it as:

A computed reference to the resolved colors of the current theme.

However, the runtime implementation iterates over all registered themes and returns Record<string, Colors> where the outer key is the theme, not just the current theme's colors.

By the way, I always wondered, why not have interface augmentation so we would have type-safe accessing of theme colors? Right now, Colors is Record<string, string>, so there's no autocomplete or typo protection:

const theme = useTheme()

theme.colors.value['light'].primary   // works but no autocompletion
theme.colors.value['light'].primray   // silent typo — no error

Something like an augmentable ThemeColorOverrides interface would make this type-safe without breaking existing behavior.

Thanks in advance🙏🏻

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions