TS2322: Property 'css' does not exist...
See original GitHub issueemotion
: version: 10.0.7emotion-theming
: 10.0.7@emotion/core
: version: 10.0.7@emotion/styled
: version: 10.0.7@emotion/cache
: version: 10.0.react
version: 16.7.0typescript
version: 3.2.4
Relevant code:
tsconfig.json
:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"checkJs": false,
"downlevelIteration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "preserve",
"lib": ["webworker", "esnext", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": false,
"noUnusedLocals": false,
"outDir": "./build/",
"pretty": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": false,
"strictNullChecks": false,
"suppressImplicitAnyIndexErrors": true,
"target": "esnext",
"types": ["@emotion/core", "jest", "node", "webpack-env"]
},
"include": ["./src/**/*", "./monaco.d.ts"],
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"gamma.config.js"
]
}
Example TS error:
TS2322: Type '{ children: Element; css: SerializedStyles; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
pragma
/** @jsx jsx */
import { jsx, css } from '@emotion/core'
import * as React from 'react'
...
Related Issues:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:27
- Comments:17 (1 by maintainers)
Top Results From Across the Web
reactjs - error TS2322: Property 'css' does not exist on type ...
However, i'm running into the following issue: error TS2322: Type '{ children: string; css: string; }' is not assignable to type ' ...
Read more >property 'css' does not exist on type 'intrinsicattributes - You.com
ts(2322 ) Property children does not exist on type 'Intrinsic attributes and Props'. Asked Aug 4, 2020 • 27 votes 2 answers. QUESTION...
Read more >TypeScript - Emotion
The easiest way to use the css prop with TypeScript is with the new JSX transform and the jsxImportSource TSConfig option (available since...
Read more >【React, Typescript】Emotion入れたら “Property 'css' does ...
Emotion入れたら "Property 'css' does not exist on type ' ... TS2322: Property 'css' does not exist.
Read more >'css' does not exist on type 'DetailedHTMLProps...' with new JSX
Error | 'css' does not exist on type 'DetailedHTMLProps. ... Type '{ children: Element[]; css: SerializedStyles; }' is not assignable to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For Emotion 11 use the following configuration in your
tsconfig.json
until TypeScript 4.1 comes out:Documentation: https://emotion.sh/docs/emotion-11#css-prop-types
TL;DR: for React 17, Typescript 4.2, Emotion 11.1
tsconfig.json
This seems to be the cleanest solution that works for me that does NOT require:
/// <reference types="@emotion/react/types/css-prop" />
to a.d.ts
file/** @jsxImportSource @emotion/react */
with any importsSee: Emotion TypeScript
css
prop docsAdditional Context:
Prior comments and the Emotion 11 docs linked in prior comments seemed to suggest that upgrading to a version of TypeScript > 4.1 would somehow resolve this issue (and by “resolve” I presumed this would mean removing the need for either the suggested
tsconfig.json
changes, or the other change suggested by a few others above on adding a/// <reference types="@emotion/react/types/css-prop" />
line in some.d.ts
file in your codebase. Unfortunately this doesn’t seem to be case.