Property 'css' does not exist on type 'DetailedHTMLProps'
See original GitHub issueHey, thank you all for this wonderful library.
I have recently adopted TypeScript
and keep running into problems with the css
prop. I couldn’t find anything about my issue in the sc typescript docs. Any help is greatly appreciated.
Environment
## System:
- OS: Windows 10
- CPU: (4) x64 Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
- Memory: 16.58 GB / 23.94 GB
## Binaries:
- Node: 11.6.0 - C:\Program Files\nodejs\node.EXE
- Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
- npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
## package.json
- "@types/styled-components": "4.1.14",
- "typescript": "3.4.5",
- "styled-components": "4.2.0",
- "react": "16.8.6",
- "react-dom": "16.8.6",
- "react-scripts": "3.0.0",
Reproduction
https://codesandbox.io/s/6vp2yzj01k
Steps to reproduce
- Use TypeScript with styled-components
- Pass
css
prop to any React element
Expected Behavior
No type error
Actual Behavior
Type '{ children: (number | Element)[]; css: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.ts(2322)
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
reactjs - error TS2322: Property 'css' does not exist on type ...
Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'. Here is a basic code example: import ...
Read more >TS2322: Property 'css' does not exist... · Issue #1249 - GitHub
Example TS error: TS2322: Type '{ children: Element; css: SerializedStyles; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes< ...
Read more >property 'css' does not exist on type 'intrinsicattributes - You.com
I'm using React, Typescript and Swiper. I'm also on Shopify Hydrogen with server components. Which maybe preventing the files from finding the type...
Read more >emotion中React的typeScript使用说明 - 会飞的猪9527
... 的css样式没有生效的,反而会报错,报错信息如: Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, ...
Read more >TypeScript - Emotion
These definitions infer types for css properties with the object syntax, ... On the other hand, there's no reason not to use @emotion/babel-plugin...
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
Apparently the problem lies in the fact that importing
import {} from "styled-components/cssprop";
doesn’t resolve correctly on Yarn. Didn’t found the culprit, but found a solution. For everyone reaching this issue, you can extract all the content directly in astyled.d.ts
(probably the same file where you define the theme shape):