[TypeScript] Property 'children' does not exist on type 'ReactNode' 해결하기

context 관련 공부 중 children 부분에서 Property 'children' does not exist on type 'ReactNode' 라는 오류가 나는 상황이 발생하였습니다.

const ColorProvider = ({ children }: ReactNode) => {
	...
}

 

function component 에서 children이 빠지게 되어 나오는 오류라고 합니다.

직접 인터페이스를 만들어 해결할 수 있습니다.

interface Props {
	children: ReactNode;
}

const ColorProvider = ({ children }: Props) => {
	...
}

 

참고

- https://stackoverflow.com/questions/55370851/how-to-fix-binding-element-children-implicitly-has-an-any-type-ts7031