stitchesjs / stitches

[Not Actively Maintained] CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience.
https://stitches.dev
MIT License
7.75k stars 253 forks source link

Type error: Type is not assignable to type #1052

Open jahirfiquitiva opened 2 years ago

jahirfiquitiva commented 2 years ago

Bug report

Describe the bug

I'm getting the following error:

Shot 2022-07-03 at 21 14 57@2x

I'm not sure what could be causing that, but here's my repository in case you can give it a look. https://github.com/jahirfiquitiva/jahir.dev/tree/dev

Thanks in advance

System information

rothsandro commented 2 years ago

It seems that you have some circular dependency in your types. Your theme includes the utils which in turn rely on the type of the theme to define the return value.

theme <-- StitchesCSS <-- UtilFunc <-- UtilsObject <-- marginUtils <-- utils <-- theme

Quick fix is to remove the type of your marginUtils UtilsObject<PropertyValue<'margin'>> (and same for paddingUtils). But there is probably a better way to fix this...

jahirfiquitiva commented 2 years ago

@rothsandro I tried changing the type used there, to this:

export type UtilFunc<T> = (value: T) => Record<string, unknown>;

export type UtilsObject<T> = Record<string, UtilFunc<T>>;

but still isn't working 😕

jahirfiquitiva commented 2 years ago

oh, removing the whole type from those utils files worked, yeah... I wish I could type them tho 🤔 Thanks!