C.W.K.
Stream
Lesson 05 of 05 · published

`tsconfig.json` 심층

~9 min · tooling, tsconfig, configuration

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete
"tsconfig 가 100+ 옵션. 대부분 시간 10개가 가장 중요."

대부분 중요한 옵션

  • `target` — emit 할 JavaScript 버전. `ES2022` 가 modern default; 더 옛 target 이 문법 down. 너의 runtime 과 match.
  • `module` — emit 할 module 시스템. Node ESM 엔 `NodeNext`, bundler 엔 `ESNext`, legacy Node 엔만 `CommonJS`.
  • `moduleResolution` — import 어떻게 resolve. Modern Node 엔 `NodeNext`, Vite/esbuild 엔 `Bundler`.
  • `strict` — 안전 meta-flag. 항상 `true`. 다음 트랙에서 자세히 다룸.
  • `esModuleInterop` — CommonJS interop 더 sane 하게. `true` 설정.
  • `skipLibCheck` — `.d.ts` 파일에 타입 체크 스킵. 대부분 프로젝트엔 `true` (더 빠르고, library 타입 어차피 못 고침).
  • `forceConsistentCasingInFileNames` — import 의 case mismatch 잡음 (`./MyFile` vs `./myfile`). 항상 `true`.
  • `outDir` — compile 된 JS 가는 곳 (emit 할 때만 중요).
  • `rootDir` — source TS 오는 곳. outDir 와 쌍.
  • `include` / `exclude` — 파일 패턴. `include: ['src']` 가 전형적; `exclude` 가 보통 node_modules + dist default.

tsconfig base

npm 의 `@tsconfig/*` 패키지가 흔한 시나리오용 pre-tuned tsconfig base 제공. extends: "@tsconfig/node20" 가 Node 20 의 옳은 default 상속. 이것들 써 — 지루한 부분 cover 하고 너가 프로젝트 specific 에 집중하게.

알려진 좋은 base 로 시작, 필수만 override. 새 tsconfig 의 모든 옵션 손-tuning 이 낭비; 커뮤니티가 sensible default 에 수렴. 그것들 써.

Code

2 tsconfig — 명시와 상속·json
// tsconfig.json — Node ESM 프로젝트용 sensible 2026 default.
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,

    "verbatimModuleSyntax": true,
    "noUncheckedIndexedAccess": true,

    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

// Base 확장:
{
  "extends": "@tsconfig/node20/tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist"
  },
  "include": ["src/**/*"]
}

External links

Exercise

Fresh 프로젝트의 tsconfig.json 들고 와. compilerOptions 를 extends: "@tsconfig/node20" 으로 대체. tsc --noEmit 돌리고 뭐 (있으면) 깨지는지 봐. 깨짐이 보통 latent issue 잡는 strict flag.
Hint
모든 게 여전히 컴파일하면 너의 프로젝트가 이미 strict. 깨짐 나타나면 base 가 자기 일 함 — 옛 config 가 놓친 gap 잡음.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.