혼자 고민해보기_ 개발/TIL (Today I Learned)

20230712(수)_ typescript 공부

nuri-story 2023. 7. 12. 12:12

금일 달성 항목

1) 코딩알려주는 누나 타입스크립트 강의 듣기

2) 후발대 강의 수강 (테스트 코드)


문제 해결 과정 1 - error TS18003

[문제]

cmd + shift + B 를 하면 tsc:build라는 것이 뜨는데 그걸 실행하면 

error TS18003: No inputs were found in config file '/Users/hyerim/typescript/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["./"]'.

오류가 자꾸 뜨는 현상이 나타났습니다.

 

[시도]

https://velog.io/@sooran/tsconfig.json-%EC%A0%9C%EB%8C%80%EB%A1%9C-%EC%95%8C%EA%B3%A0-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0

 

{ tsconfig.json } 제대로 알고 사용하기

tsconfig.json을 왜 그리고 무엇을 위해서 설정하는지 알아보고자 한다.

velog.io

https://github.com/Microsoft/TypeScript/issues/17155

 

error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["src/**/*"]' and 'exclude'

can't parsing tsconfig.json error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["src/**/*"]' and 'exclude' paths were '["node_modules"]'. tsconfig.j...

github.com

등등 다양하게 진입하여 시도해보았지만 해결이 안되었습니다. 

 

[해결]

튜터님과 문구를 확인해보니 jscofing.json 의 include 와 exclude가 모두 전역으로 설정되어있어서 생긴 문제였습니다.

코딩알려주는 누나의 강의에서는 include와 exclude가 설정되어있지 않았고 실행했을때 기본값인 

{
  "compilerOptions": {
    "outDir": "./", //js파일 아웃풋 경로바꾸기
    "target": "es6", // 'es3', 'es5', 'es2015', 'es2016', 'es2017','es2018', 'esnext' 가능
    "module": "commonjs", //무슨 import 문법 쓸건지 'commonjs', 'amd', 'es2015', 'esnext'
    "lib": ["ES6"],

    "sourceMap": true
  },
  "include": ["**/*"],
  "exclude": ["./"]
}
  "include": ["**/*"],
  "exclude": ["./"]

이 실행되어 나타나는 현상이었습니다.

 

아래와 같이 include와 exclude 모두 다른 파일로 각각 설정해주니 tsbuild가 잘 생성되었습니다.

{
  "compilerOptions": {
    "outDir": "./", //js파일 아웃풋 경로바꾸기
    "target": "es6", // 'es3', 'es5', 'es2015', 'es2016', 'es2017','es2018', 'esnext' 가능
    "module": "commonjs", //무슨 import 문법 쓸건지 'commonjs', 'amd', 'es2015', 'esnext'
    "lib": ["ES6"],

    "sourceMap": true
  },
  "include": ["src"],
  "exclude": ["./test"]
}

 

 

[알게된 점]

챗 gpt에 물어봐도 빨리 해결 할수 있었을 것 같다고 하셔서 다음부터는 챗 gpt로 적극적으로 사용할 예정입니다.