TypeScript를 js로 컴파일 한 경우 문제가 없지만
빠르게 작업하기 위해 dev 환경에서는 ts-node
로 컴파일 없이 작업 하려 했더니 문제가 생겼다.
tsconfig.json
에 명시한 typeRoots
가 작동을 안했던 것 이다.
ts-node
문서를 찾아보니 --files
옵션을 사용 하지 않는 경우
tsconfig.json의 files
, include
, exclude
가 default 로false
된다고 한다.
추가 --files 옵션을 사용하지 않으면
"files":[], "include": []
로 override 된다.
tsc --traceResolution 옵션을 통해 추적 할 수 있다.
둘 중 하나를 적용하면 된다.
{
"compilerOptions": {
...
},
"ts-node": {
"files": true
}
}
"scripts": {
"build": "tsc",
"dev": ": ts-node --files src/@types/index index.ts"
},
ts-node
7 버전이상 부터.
https://github.com/TypeStrong/ts-node#typechecking
https://github.com/TypeStrong/ts-node/issues/1132#issuecomment-716642560
감사합니다 정확히 제가 찾던 문제인데 많은 도움이 되었습니다