Tailwind-Styled-Component icon indicating copy to clipboard operation
Tailwind-Styled-Component copied to clipboard

fix for typescript error on strict builds

Open jblossomweb opened this issue 9 months ago • 0 comments

Hello!

I was using tailwind-styled-components in another project, and when I ran my build, it was getting caught on a Typescript error coming from this package:

> tsc && vite build

node_modules/tailwind-styled-components/dist/tailwind.d.ts:27:81 - error TS2344: Type 'P' does not satisfy the constraint '{}'.

27 declare type TailwindPropHelper<P, O extends object = {}> = PickU<MergeProps<O, P>, keyof MergeProps<O, P>>;
                                                                                   ~

  node_modules/tailwind-styled-components/dist/tailwind.d.ts:27:33
    27 declare type TailwindPropHelper<P, O extends object = {}> = PickU<MergeProps<O, P>, keyof MergeProps<O, P>>;
                                       ~
    This type parameter might need an `extends {}` constraint.

node_modules/tailwind-styled-components/dist/tailwind.d.ts:27:105 - error TS2344: Type 'P' does not satisfy the constraint '{}'.

27 declare type TailwindPropHelper<P, O extends object = {}> = PickU<MergeProps<O, P>, keyof MergeProps<O, P>>;
                                                                                                           ~

  node_modules/tailwind-styled-components/dist/tailwind.d.ts:27:33
    27 declare type TailwindPropHelper<P, O extends object = {}> = PickU<MergeProps<O, P>, keyof MergeProps<O, P>>;
                                       ~
    This type parameter might need an `extends {}` constraint.


Found 2 errors in the same file, starting at: node_modules/tailwind-styled-components/dist/tailwind.d.ts:27

So I figured I would submit a fix, based on Typescript's suggestion. This extends object for an input type in 2 places, similarly to adjacent input types.

All tests pass, and the package builds. Happy to respond to any questions! Let me know if/when this can be bundled into the next version, as I'll be maintaining a fork for my project in the meantime.

Thank you!

jblossomweb avatar Oct 22 '23 18:10 jblossomweb