728x90
@types/react/index.d.ts의 HTMLAttributes interface에 css 속성이 없는데, 추가하려고 하니 타입 에러가 발생
(해당 코드: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L1843-L1909)
해결 방법
1. tsconfig.json > compileOptions 에 types 추가
|
// tsconfig.json |
|
{ |
|
"compilerOptions": { |
|
"types": ["@emotion/react/types/css-prop"] |
|
} |
|
} |
2. styles.d.ts 추가
styled.d.ts 파일을 추가하고, 아래 코드를 추가
/// <reference types="@emotion/react/types/css-prop" />
emotion 공식 홈페이지 설명
728x90
'TypeScript 끄적끄적' 카테고리의 다른 글
tsx로 컴포넌트를 만들고 png이미지를 import할때 오류 해결 방법 (0) | 2022.11.25 |
---|---|
'{ children: never[]; }' 유형에 'IntrinsicAttributes' 유형과 공통적인 속성이 없습니다.ts(2559) (0) | 2022.11.23 |