ZZIPSA / kkuk-kkuk-fe

스탬프랠리 웹앱 '꾹꾹'의 프론트엔드 리포지토리
https://kkuk-kkuk-fe.vercel.app
0 stars 1 forks source link

`/kits/new` 파일 관련 오류 #30

Closed 2chanhaeng closed 3 months ago

2chanhaeng commented 3 months ago

기대한 동작

/kits/new 페이지가 렌더링 됩니다.

실제 동작

정적 페이지 생성 과정에서 ReferenceError: FileList is not defined 가 발생합니다.

재현 방법

pull 3cc2951c6a0463f0c98e74468d0c7460f682de96

원인

@/app/kits/new/components/NewKitForm/schema.ts 에서 FileList 클래스를 사용하는데 서버에는 FileList 클래스가 존재하지 않기 때문에 발생한 오류입니다.

해결

f9ec7874fb8d34b4dc1eaf5084df65358d5b8e35 FileList is not defined - ReactHookForm+zodwith Next js and typescript #11096 를 참조해 먼저 unknown으로 추측한 뒤 FileList | null | undefined 로 제한한 후 nullable 를 제외해 FileList 로 추측하게 만들었습니다. 이렇게 하면 타입은 FileList로 추측되어 type-safety 함과 동시에 FileList 는 클래스가 아닌 타입으로서만 사용되므로 빌드 오류가 발생하지 않습니다.

2chanhaeng commented 3 months ago

31 으로 해결