TypeScript and ThemeProvider support for props
See original GitHub issueWhen using a component it’s good to ensure that no one can provide a value that the component can’t accept. My VsCode autosuggested:
<PadBox padding="xlXXl" />
And typescript doesn’t yell. How can we make Bedrock typesafe?
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Theme with styled-components and Typescript - Medium
Theming in styled-components allows your app to support multiple design patterns within the same app. Imagine an amazing code editor with no ...
Read more >StyledComponents with Typescript and ThemeProvider. What ...
Inside your src folder, create a new folder named @types and put your file styled.d.ts inside this folder. The content is the same...
Read more >Typescript ThemeProvider + Props #802 - emotion-js ... - GitHub
Hello, Does anyone know of a way to use TypeScript with ThemeProvider & Props? I have a ThemeProvider like export default { color:...
Read more >API Reference - styled-components
Any valid React component that can handle a theme prop. Returns the passed component inside a wrapper (higher order component).
Read more >Create styled.d.ts to make Typescript work with styled ...
The ThemeProvider injects an object of type DefaultTheme into every prop and the definition for DefaultTheme is just {} . Take a look...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
xlXXl is coming from: https://github.com/Bedrock-Layouts/Bedrock/blob/922d8708104061e261d53ace8ddf3a05f9c1cb78/packages/spacing-constants/src/index.tsx and isn’t one of the valid options for PadBox.
I guess you could first make sure that each component returns the types for each prop, that happen to match to the themeProvider keys… But better would be to get the typing from styled-components (Which is possible) https://styled-components.com/docs/advanced#via-withtheme-higherorder-component
But maybe option 1 is fine and proper. You can integrate storybook to read the Interfaces and document them automatically based on that, which would help your long term maintenance and accuracy issues.
Ah I see how can we scope them to only the provided values in the theme provider. I’m going to need to look into this.