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

TypeScript issue with PropertyValue and TS v4.8.2 #1078

Closed csantos1113 closed 1 year ago

csantos1113 commented 1 year ago

Bug report

Describe the bug

using PropertyValue for defining a custom util in TypeScript 4.8.2 generates the following typescript error:

TS4118: The type of this node cannot be serialized because its property '[$$PropertyValue]' cannot be serialized.

To Reproduce

I cannot reproduce this in codesandbox because I can't change the TypeScript version (See: https://github.com/codesandbox/codesandbox-client/issues/942)

  1. Create a react server with typescript 4.8.2
  2. Create stitches config
const stitches = createStitches({
  utils: {
    marginHorizontal: (value: PropertyValue<'margin'>) => ({
      marginLeft: value,
      marginRight: value
    })
  }
});

export const { css, config, createTheme, getCssText, globalCss, keyframes, reset, styled, theme } =
  stitches;
  1. notice the TS error

Expected behavior

I should be able to use PropertyValue on TS 4.8.2

Screenshots

Screen Shot 2022-09-02 at 10 19 26 AM

System information

jackguoAtJogg commented 1 year ago

I'm not sure how many people have this issue experience. I'm on Typescript 4.5.2 and getting the same error, and the error came out from no where.

domcoleman commented 1 year ago

I'm not sure how many people have this issue experience. I'm on Typescript 4.5.2 and getting the same error, and the error came out from no where.

If you're using VS Code you can switch to the workspace version of TypeScript, by default it will use VS Code's version.

Screenshot 2022-09-06 at 10 30 00
jackguoAtJogg commented 1 year ago

@domcoleman Thank you! That worked for me 😁

gabrieloureiro commented 1 year ago

Any update? The both version of typescript (vsc and node_modules) are reporting this error.

What is the stable version for stitches?

Screen Shot 2022-09-08 at 09 53 28

Screen Shot 2022-09-08 at 09 54 22

jakubzet commented 1 year ago

Any update? The both version of typescript (vsc and node_modules) are reporting this error.

What is the stable version for stitches?

Screen Shot 2022-09-08 at 09 53 28

Screen Shot 2022-09-08 at 09 54 22

@gabrieloureiro You're using the same TypeScript versions in both cases - this can be easily spotted on the screenshot you attached. The last TS version which doesn't throw errors is 4.7.4. Find your package.json file and force appropriate TS version, then reinstall packages and select one from node_modules.

gabrieloureiro commented 1 year ago

Any update? The both version of typescript (vsc and node_modules) are reporting this error. What is the stable version for stitches? Screen Shot 2022-09-08 at 09 53 28 Screen Shot 2022-09-08 at 09 54 22

@gabrieloureiro You're using the same TypeScript versions in both cases - this can be easily spotted on the screenshot you attached. The last TS version which doesn't throw errors is 4.7.4. Find your package.json file and force appropriate TS version, then reinstall packages and select one from node_modules.

The version 4.7.4 works well for me. Thank you @jakubzet.

Andarist commented 1 year ago

Since this has changed between 4.7 and 4.8 - is there any TS issue to track this specific regression/change on their side?

dzek69 commented 2 months ago

To anyone still using stitches like me, and wanting to upgrade TypeScript, do this:

All thanks should go to @jgoz (who fixed that) and @gajus (who created a patch file I slightly modifed). I hope did not miss anyone.