Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Using @emotion/core in my React app

Picture1 Please help, these errors are preventing my react app from compiling. How do I fix it? I also attached a picture of the App.tsx file What is another suggestion for taking care of this error?

Could not find a declaration file for module '@emotion/core'. 'c:/Users/nwoko/source/repos/QandA/QandAfrontend/frontend/node_modules/@emotion/core/dist/emotion-core.cjs.js' implicitly has an 'any' type. Try npm i --save-dev @types/emotion__core if it exists or add a new declaration (.d.ts) file containing declare module '@emotion/core';ts(7016)

Type '{ children: Element[]; css: any; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'. Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'.ts(2322)

Picture2

like image 975
KingNOB Avatar asked Jan 24 '23 13:01

KingNOB


2 Answers

Capitalizing on @sanderdebr suggestion,

I ran npm install --save @emotion/react before changing the import line to import { jsx, css } from '@emotion/react' and got rid of TypeScript error TS7016

I then added "types": ["@emotion/react/types/css-prop"] in file tsconfig.json to get rid of the second ts error (2322)

like image 87
oldbrazil Avatar answered Mar 08 '23 03:03

oldbrazil


Helped me:

tsconfig.json

"types": ["@emotion/react/types/css-prop"],

*.tsx

/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx, css } from "@emotion/react";
like image 41
Sergey Avatar answered Mar 08 '23 03:03

Sergey