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

`strict: true` 와 Family Flag

~8 min · strict-mode, strict, tsconfig

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete
"`strict: true` 가 meta-flag. 7개 체크가 하나로 켜짐."

Family

Tsconfig.json 의 "strict": true 가 7개 별개 strictness flag 동시에 켜:

  • noImplicitAny
  • strictNullChecks
  • strictFunctionTypes
  • strictBindCallApply
  • strictPropertyInitialization
  • noImplicitThis
  • useUnknownInCatchVariables

각각 단독으로도 의미 있음; 다 함께 켜는 게 2026 의 새 TypeScript 프로젝트 default.

왜 다 함께

7 flag 가 다른 종류의 latent 타입 약점 잡음. 하나만 켜고 다른 거 안 켜면 gap 남음. 권장 자세가 첫날부터 `strict: true` — 모든 flag, 예외 없음.

Full strict 못 가는 프로젝트 엔 (legacy 코드, 점진적 migration), 개별 flag 한 번에 하나씩 opt out 가능. 일반 방향이 항상 덜 strict 가 아니라 더 strict 로 가야.

strict 가 끝 아냐

3개 추가 flag 가 `strict: true` 도 놓치는 거 잡음:

  • noUncheckedIndexedAccess — index 접근을 T | undefined 로 타입
  • exactOptionalPropertyTypes — 빠진 거와 명시 undefined 구별
  • noImplicitReturns — 함수가 모든 code path 에 뭔가 반환해야

새 프로젝트엔 이것들도 켜. `@tsconfig/strictest` base 가 다 포함.

최대-strict tsconfig 가 옳은 시작점. 모든 flag 가 자기 몫 하고; 잡는 모든 버그가 나중 디버깅 세션 절약. Strict 로 시작, strict 유지.

Code

최대-strict tsconfig·json
// tsconfig.json — full strict + extra flag.
{
  "compilerOptions": {
    "strict": true,
    // 위 7 sub-flag 가 strict: true 켜지면 암묵.
    // strict:true 에 없는 extra-strict flag:
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    // 흔한 companion:
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "verbatimModuleSyntax": true
  }
}

// 또는 커뮤니티 'strictest' base 상속만:
{
  "extends": "@tsconfig/strictest/tsconfig.json"
}

External links

Exercise

새 프로젝트에서 strict: true 와 이 lesson 의 3 extra flag 활성화. 의도적으로 loose 한 줄 몇 (annotation 없는 param, 가능 null 접근, 가능 out-of-bounds index 접근) 쓰고 각 flag 발동 관찰. 하나 켜놓고 하나 비활성화 — 코드가 다르게 어떻게 느끼는지 적어.
Hint
Extra flag 가 strict: true 만으론 발동 안 함. 각각 다른 카테고리의 latent 안전 부족 잡음. 실제 코드에 발동하는 거 한 번 보면 영구히 켜놓고 싶어져.

Progress

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

댓글 0

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

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