emotion-js / emotion

👩‍🎤 CSS-in-JS library designed for high performance style composition
https://emotion.sh/
MIT License
17.5k stars 1.11k forks source link

Type errors in `@emotion/cache` and `@emotion/utils` #3218

Open Methuselah96 opened 3 months ago

Methuselah96 commented 3 months ago

Current behavior:

There are two new type errors related to missing dependencies that have popped up in the past week:

Error: ./node_modules/@emotion/cache/dist/declarations/types/index.d.ts(4,23): error TS2688: Cannot find type definition file for 'node'.
Error: ./node_modules/@emotion/utils/dist/declarations/src/types.d.ts(1,33): error TS2307: Cannot find module '@emotion/sheet' or its corresponding type declarations.

To reproduce:

  1. Start a TypeScript project with @emotion/react using a strict package manager (e.g., pnpm or Yarn PnP) and with skipLibCheck set to false

Expected behavior:

No type errors

Environment information:

fdw commented 3 months ago

I think this also breaks our types, because @emotion/cache now references @types/node, even though our project runs in the browser and has slightly different types for built-in functions.

Andarist commented 3 months ago

I'm working on removing the incorrect node references here: https://github.com/emotion-js/emotion/pull/3219

As to the other problem with @emotion/utils depending on @emotion/sheet... I have to think about it a little more. I'll fix this in the coming days.

StreetStrider commented 3 months ago

@Andarist hello. It looks like an ordinary hoisting problem. I've recently updated some of my emotion-related deps and stumbled upon this. In my case I used public-hoist-pattern[]=@emotion/sheet (pnpm). I think there's missing dependency on types from utils → sheet. Lifting sheet solves the issue for me.

    "@emotion/react":
      "11.13.0",