Open bryanjswift opened 1 year ago
Same issue arises with headlessui/react
. See: https://github.com/tailwindlabs/headlessui/issues/2468
In my case, I removed "jsxImportSource": "@emotion/react"
from tsconfig.json and put "types": ["@emotion/react/types/css-prop"]
instead, and it built without error.
@nagayama your solutions works !
Note for Next, you need to change next.config.js
in order to avoid error Warning: Invalid value for prop
csson <div> tag.
/** @type {import('next').NextConfig} */
const nextConfig = {
compiler: {
emotion: true,
}
}
Source: https://nextjs.org/docs/architecture/nextjs-compiler#emotion
In my case, I removed
"jsxImportSource": "@emotion/react"
from tsconfig.json and put"types": ["@emotion/react/types/css-prop"]
instead, and it built without error.
Also tried @nagayama's solution, however i still get
Property css does not exist on type
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement
// tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"moduleResolution": "node",
"typeRoots": ["./node_modules/@types", "./types"],
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsxImportSource": "@emotion/react",
"incremental": true,
"checkJs": true,
"noUncheckedIndexedAccess": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"pretty": true,
"removeComments": true,
"downlevelIteration": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": false,
"outDir": "dist",
"declaration": false,
"sourceMap": true,
"module": "esnext",
"importHelpers": true,
"baseUrl": ".",
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
".eslintrc.cjs",
"next-env.d.ts",
".next/types/**/*.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.mjs"
],
"exclude": ["node_modules"],
}
Current behavior:
Simple components are producing
TS2590: Expression produces a union type that is too complex to represent
when using@chakra-ui/system
to 2.5.5 andtypescript
to 5.0.3. Below is a minimal case.This appears to be an interop problem with type modifications in
@chakra-ui/react
or@chakra-ui/system
and@emotion/react
. The type error is eliminated if the the"jsxImportSource": "@emotion/react"
is dropped fromtsconfig.json
though that has other consequences. I have opened a related issue in@chakra-ui
, see https://github.com/chakra-ui/chakra-ui/issues/7526Still produces an error for me with this configuration.
To reproduce:
yarn tsc
Expected behavior:
Types should not conflict as a result of
jsxImportSource
Environment information:
react
version: 18.2.0@emotion/react
version: 11.10.6