Open
Description
openedon Oct 15, 2023
Package
@carbon/react
Browser
No response
Package version
1.40
React version
17
Description
Here's a piece of my own code:
const [userTheme, setUserTheme] = useState<string>("white");
...
<Theme theme={userTheme}>
This is now a TS error because the theme
prop is typed as a list of specific strings, but sadly is not exported anywhere that I can find. Here is the only place I've found it defined in your source:
interface GlobalThemeProps {
theme?: 'white' | 'g10' | 'g90' | 'g100';
children?: React.ReactNode;
}
To workaround this, end users have to make their own type definition by copy/pasting the string values, like this:
export type CarbonThemeType = "white" | "g10" | "g90" | "g100";
And then to get rid of the error:
const [userTheme, setUserTheme] = useState<CarbonThemeType>("white");
Reproduction/example
see description
Steps to reproduce
see description
Suggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
CDD Hub
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate problems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Type
Projects
Status
⏱ Backlog