본문 바로가기
ERROR

[React-TypeScript] Type 'oo' is not assignable to type 'IntrinsicAttributes & 'xxx'. Property '' does not exist on type 'IntrinsicAttributes & 'xxx''.

by sun_HY 2022. 11. 12.

그냥 map으로 컴포넌트에 값을 넣으려고 했을 뿐인데 자꾸 빨간줄이 떴다.

error_1

커서를 올려보니 대충 타입이 안 맞는다는 오류인듯

error_2

GroupListItem이라는 하위 컴포넌트에 타입 지정을 해놓긴 했었는데 props로 객체를 보낼 거라서 한 단계 더 지정해주어야 했던 것 같다.

error_3

 

current_type

 

// 해결 방법

solution_1

interface 안에 object로 한 번 더 구분해서 타입을 지정해주면 잘 들어간당 keyError를 방지한 index number도 같이 넣어줌

solution_2

 

728x90