최종 코드


// frontend/src/custom.d.ts
declare module "sockjs-client/dist/sockjs";

에러 메시지


src/routes/LiveChat.tsx(11,20): error TS7016: Could not find a declaration file for module 'sockjs-client/dist/sockjs'. '/var/jenkins_home/workspace/cicdtest/frontend/node_modules/sockjs-client/dist/sockjs.js' implicitly has an 'any' type. Try npm i --save-dev @types/sockjs-client if it exists or add a new declaration (.d.ts) file containing declare module 'sockjs-client/dist/sockjs';

→ 여기서 제안하는 방식인

  1. npm install 이건 안 통한다

  2. declare module 결국 이방식으로 한건데, 대체 파일을 어디 넣으란 말인가? 하면

    프로젝트 상단에 넣으라고 한다.

    — 근데 안됨. 결국 src 디렉토리에 넣으니까 됐음

  3. 다르게 생각한 방법 >> import 경로를 dist/sockjs 이렇게 깊이 들어가지 않고 단순히 sockjs-client 이렇게 설정해봤다. 코드단에서 오류가 안남. 근데 실행하면 소켓 오류가 난다.

덧붙여…


import InfiniteScroll from "react-infinite-scroller";

이친구도 같은 에러가 났고, 같은 방법으로 해결했다.