ben-rogerson / twin.macro

🦹‍♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, solid-styled-components, stitches and goober) at build time.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Property 'cs' is missing in type....

OnkelTem opened this issue · comments

For some time now we've been getting this error:

Property 'cs' is missing in type '{ children: (ReactNode | Element)[]; ref: RefObject<HTMLDivElement> | null | undefined; css: any; }' but required in type 'Pick<ModalWindowProps, keyof MotionProps | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | ... 248 more ... | "cs">'.ts(2741)

I think it may be related to the update of @types/react which is now 18.2.38.

I didn't have time to investigate it.

twin.macro version: 3.4.0.

Hey there

I haven't heard if this error popping up before, my guess is that it's related to the cs type defined here.
The cs prop is an alternative spot to add twins "short css" classes (instead of alongside tw classes), this feature was added before tailwind released their own version of the feature so it's due for removal in a future version of twin.

As for a fix, perhaps you could try overriding the type in one of your own myProject.d.ts files:

declare module 'react' {
  interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
    cs?: never
  }
}

@ben-rogerson Thanks, I'll try it!