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.73k stars 249 forks source link

Cannot use stricter experience + custom utils #1077

Closed csantos1113 closed 1 year ago

csantos1113 commented 1 year ago

Bug report

Describe the bug

TypeScript fails when trying to use the "stricter experience" (See docs) plus "custom utils" (See docs)

stitches.config.ts

export const { globalCss, styled, theme } = createStitches({
  theme: {
    space: {
      small: "8px",
      large: "20px"
    }
  },
  utils: {
    paddingHorizontal: (value: PropertyValue<"padding">) => ({
      paddingLeft: value,
      paddingRight: value
    }),
    paddingVertical: (value: PropertyValue<"padding">) => ({
      paddingTop: value,
      paddingBottom: value
    })
  }
});

Usage

import { styled, theme } from "../stitches.config";

<Box
  css={{
    margin: theme.space.small,
    padding: theme.space.small,
    paddingVertical: theme.space.large // this line fails
  }}
>
  Stricter experience
</Box>

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to https://codesandbox.io/s/stricter-experience-utils-6wstvq
  2. Notice the TypeScript error in line image

Expected behavior

I should be able to pass theme tokens to custom utils and not have TypeScript complaining about it

Screenshots

System information

csantos1113 commented 1 year ago

Closed in favor of #844 (it's a dup)