TS error when using `as` + variant with composed components
See original GitHub issueTo repro:
const Box = styled('div', {
variants: {
size: {
small: {}
}
}
});
const Flex = styled(Box, {})
export function Component() {
return <Flex as="article" size="small" />;
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Typescript error when sharing styles across components that ...
I am creating a variable called sharedTypo using the css function, to share styles across components. It has variant called variant with a...
Read more >Typescript styled-component error: "Type '{ children: string
I found a great solution that has nothing to do with typescript or styled-components. It is enough to create a node through React.createElement....
Read more >Composing React Components with TypeScript - Pluralsight
Introduction. In this guide, you will learn how to compose React.js components using the compile-to-JavaScript language, TypeScript.
Read more >TypeScript errors and how to fix them
error TS1337: An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead. Broken...
Read more >Build strongly typed polymorphic components with React and ...
If you go ahead and use this component wrongly, e.g., passing a valid as prop with other incompatible props, you'll get an error....
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 Free
Top 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
Based on what I can see in the code, this should work:
Mind you, IIRC, React has a type for HTML element strings, but that may conflict with Stitches’ types once you try to pass it in, I’m not sure. If anyone tries it out, please let us know how it went 😃
Hi @hadihallak - I’m still seeing Polymorphic
as
typescript errors when composing components even when using the latest1.2.7-0
canary build (unless I’m misunderstanding how this should work with Stitches) - I’ve put together a code sandbox showing the issue here https://codesandbox.io/s/stitches-polymorphic-inheritance-typescript-error-d1xn1o?file=/src/Paragraph.component.tsx