We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as
When composing a styled component, typescript throws an error when using a variant prop and an as prop. The error:
No overload matches this call. Overload 1 of 3, '(props: Omit<Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "size" | "css"> & TransformProps<...> & { ...; }, "css" | "as"> & TransformProps<...> & { ...; }): ReactElement<...> | null', gave the following error. Type 'string' is not assignable to type 'undefined'. Overload 2 of 3, '(props: Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "css" | "as"> & TransformProps<...> & { ...; }): ReactElement<...> | null', gave the following error. Type '{ children: string; as: "h3"; size: string; }' is not assignable to type 'IntrinsicAttributes & Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "css" | "as"> & TransformProps<...> & { ...; }'. Property 'size' does not exist on type 'IntrinsicAttributes & Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "css" | "as"> & TransformProps<...> & { ...; }'. Overload 3 of 3, '(props: Omit<Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "size" | "css"> & TransformProps<...> & { ...; }, "css"> & TransformProps<...> & { ...; }): ReactElement<...> | null', gave the following error. Type '{ children: string; as: string; size: "xl"; }' is not assignable to type 'IntrinsicAttributes & Omit<Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "size" | "css"> & TransformProps<...> & { ...; }, "css"> & TransformProps<...> & { ...; }'. Property 'as' does not exist on type 'IntrinsicAttributes & Omit<Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "size" | "css"> & TransformProps<...> & { ...; }, "css"> & TransformProps<...> & { ...; }'.ts(2769) [styled-component.d.ts(27, 5): ]()The expected type comes from property 'as' which is declared here on type 'IntrinsicAttributes & Omit<Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "size" | "css"> & TransformProps<...> & { ...; }, "css" | "as"> & TransformProps<...> & { ...; }'
Here is a codesandbox link and code:
import "./styles.css"; import { styled } from "@stitches/react"; export const Title = styled("h1", { fontFamily: "Helvetica", margin: 0, variants: { size: { xl: { fontSize: 42 }, lg: { fontSize: 26 } } } }); const ComposedTitle = styled(Title, { marginTop: 25 }); export default function App() { return ( <div className="App"> <h1>Hello CodeSandbox</h1> <h2>Start editing to see some magic happen!</h2> <Title>Basic Title</Title> <ComposedTitle>Composed H1 Title</ComposedTitle> <ComposedTitle as="h3">Composed Title as h3</ComposedTitle> <ComposedTitle as="h3" size="xl"> // <!-- this will error Composed Title as h3 but size xl </ComposedTitle> </div> ); }
No ts error
Really enjoying stitches btw it's awesome ☺️
The text was updated successfully, but these errors were encountered:
This is a duplicate of #749 which is now fixed under a canary release. could you please upgrade to the latest canary1.2.7-0 and test again?
1.2.7-0
Sorry, something went wrong.
@hadihallak Yep can confirm in the Codesandbox 1.2.7-0 fixes this ts issue. Thankyou
No branches or pull requests
Bug report
Describe the bug
When composing a styled component, typescript throws an error when using a variant prop and an
as
prop. The error:To Reproduce
Here is a codesandbox link and code:
Expected behavior
No ts error
System information
Additional context
Really enjoying stitches btw it's awesome☺️
The text was updated successfully, but these errors were encountered: