Skip to content
New issue

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

TypeScript type error with TwImportComponent in jest-testing-typescript #849

Open
hyemingwaylikesdev opened this issue Feb 15, 2024 · 0 comments

Comments

@hyemingwaylikesdev
Copy link

hyemingwaylikesdev commented Feb 15, 2024

I'm using jest-testing-typescript from twin.macro example, but I've been facing a problem.

import tw, { styled } from 'twin.macro'

const StyledImportComponent = styled.h1(() => [tw`bg-red-500`])
const TwImportComponent = tw.div`bg-green-500`
const TwPropComponent = ({ text }: { text: string }) => (
  <div tw="bg-blue-500">{text}</div>
)

export default function Test({ text }: { text: string }) {
  return (
    <>
      <StyledImportComponent />
      <TwImportComponent />
      <TwPropComponent text={text} />
    </>
  )
}

It passed the test code, but TwImportComponent and TwPropComponent make a type error.

'TwImportComponent' cannot be used as a JSX component.
  Its type 'TwComponent<"div">' is not a valid JSX element type.
    Type 'TwComponent<"div">' is not assignable to type '(props: any, deprecatedLegacyContext?: any) => ReactNode'.
      Type 'Element' is not assignable to type 'ReactNode'.
        Property 'children' is missing in type 'Element' but required in type 'ReactPortal'.ts(2786)

Is there a solution? Thank you for reading my issue : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant