본문 바로가기
오류

[에러 해결] Type error: Type 'OmitWithTag<{ id: string; }, keyof PageProps, "default">' does not satisfy the constraint '{ [x: string]: never; }'. Property 'id' is incompatible with index signature. Type 'string' is not assignable to type 'never'.

by 개발고구마 2024. 10. 13.

nextjs 를 사용하다 아래와 같은 에러를 만났다


.next/types/app/main/detail/page.ts:28:13
Type error: Type 'OmitWithTag<{ id: string; }, keyof PageProps, "default">' does not satisfy the constraint '{ [x: string]: never; }'.
Property 'id' is incompatible with index signature.
Type 'string' is not assignable to type 'never'.

Check the prop type of the entry function
checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()

이것저것 찾아보니 결국 리액트 Page로 쓰는건 파라미터를 받을 수 없다는게 문제였다...
(서버개발만하다 UI쪽 하니까 모르는게 너무 많다)

소스 수정하고 빌드 정상확인

AS-IS
export default function Detail(param: { id: string }) {
  const [imageUrl, setImageUrl] = useState({link : '', profile : ''});

TO-BE
export default function Detail() {
  const [imageUrl, setImageUrl] = useState({link : '', profile : ''});