husky에서 타입 체크 시 아래와 같이 TS17004, TS6142, TS2307 등 다양한 타입에러가 나왔다
✖ tsc --noEmit:
src/components/footer/Footer.tsx(1,21): error TS6142: Module './NavMenu' was resolved to '/Users/kjy/repo/neighborhood-cat/src/components/footer/NavMenu.tsx', but '--jsx' is not set.
src/components/footer/Footer.tsx(3,23): error TS2307: Cannot find module '@/constants/nav' or its corresponding type declarations.
src/components/footer/Footer.tsx(19,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(22,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(25,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(28,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(31,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(36,3): error TS2698: Spread types may only be created from object types.
src/components/footer/Footer.tsx(37,26): error TS2339: Property 'href' does not exist on type 'unknown'.
src/components/footer/Footer.tsx(38,5): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(40,16): error TS2339: Property 'label' does not exist on type 'unknown'.
src/components/footer/Footer.tsx(45,5): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(46,7): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(47,9): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(48,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
src/components/footer/Footer.tsx(50,15): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
husky - pre-commit hook exited with code 1 (error)
JavaScript
복사
처음에는 TS17004 에러로 검색해 보았으나 해결책으로 제시 된 tsconfig.json 에서의 jsx 항목을 작성하거나 vscode의 typescript 버전 문제하고는 무관해보이거나 해결책을 적용해도 바뀌는 것이 없어 다른 방법을 찾아보았다.
husky의 hook 사용 시에 나온 에러였기에 lint-stage에서 자동 실행되는 tsc —noEmit 에서 발생하는 문제로 특정하고 다시 검색해보니 아래와 같은 issue를 찾을 수 있었다
답변 중에서 sombreroEnPuntas 유저가 남긴 해결책인 bash 를 통해 호출하는 방식이 도움이 되었다. husky의 hook을 통한 명령어 호출 시 파일 인식을 제대로 못할 수 있다는 것이 이유였다
해결한 후에 에러 내용을 보니 여러 종류의 오류가 섞여 있고, 실제로 개별 파일에서는 해당 오류가 나오지 않는다는 점에서 바로 config 파일에 대한 인식 오류를 의심해 보는 것이 좋았다는 생각이 들었다.