stitchesjs / stitches

[Not Actively Maintained] CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience.

Home Page:https://stitches.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript error when using `as` with multiple levels of nesting

s-h-a-d-o-w opened this issue · comments

Bug report

Describe the bug

This fix only works a single level deep.
Which might also be why some other people have said that the fix doesn't work for them. But as far as I've seen, nobody has debugged it this way and mentioned multiple levels of nesting, so I thought I should create this new issue.

To Reproduce

Insert const AnotherLevel = styled(Flex, {}) in packages/test/issue-749-react.tsx and use that instead of Flex.

Will throw

No overload matches this call.
  Overload 1 of 3, '(props: Omit<Omit<Omit<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<...>> & { ...; }, "size" | "css"> & TransformProps<...> & { ...; }, "css" | "variant"> & TransformProps<...> & { ...; }, "as" | "css"> & TransformProps<...> & { ...; }): ReactElement<...> | null', gave the following error.
    Type 'string' is not assignable to type 'undefined'.
...

Expected behavior

as prop should not throw TS errors regardless of levels of nesting.

Screenshots

Screenshot 2022-10-07 152001

System information

  • Version of Stitches: canary source

Additional context

I have looked at it a bit and TypeScript seems to generate the type recursively with the appropriate props, so I'm not sure what's going on here.

Screenshot 2022-10-07 152455

+1

Please upvote the original post instead of posting +1.