stitches icon indicating copy to clipboard operation
stitches copied to clipboard

TS error when applying default variants coming from another CSS style

Open vctormb opened this issue 2 years ago • 1 comments

Bug report

TypeScript doesn't get the variant type coming from another css style.

Describe the bug

I have a Text component where it has variants related to the font-weight style. The weight variants were extracted in another css to be reused in other styles. In this scenario I called it as cssWeightVariants. When applying the cssWeightVariants in the Text style, TypeScript doesn't know the weight variant in defaultVariants object. It only knows the variants applied directly in the Text css.

To Reproduce

const cssWeightVariants = css({
  variants: {
    weight: {
      normal: {
        fontWeight: 400,
      },
      bold: {
        fontWeight: 700,
      },
    },
  },
});

const cssText = css(
  {
    variants: {
      variant: {
        base: {
          color: "black",
        },
      },
    },
    defaultVariants: {
      variant: "base", // TS ok
      weight: "normal", // TS error here
    },
  },
  cssWeightVariants
);

Expected behavior

TypeScript should know the weight type coming from the external css style.

Screenshots

VSCode image

System information

  • OS: macOS
  • Version of Stitches: 1.2.8
  • Version of Node.js: 16.13.1

vctormb avatar Jun 08 '22 01:06 vctormb

found the same issue recently. @hadihallak any update on this?

mettz avatar Aug 23 '22 21:08 mettz