TypeScript Compiler
tsconfig 옵션이 바꾸는 타입 안전성과 출력 경계
strict, moduleResolution, target, lib, paths, outDir 같은 옵션은
코드 스타일이 아니라 컴파일러가 보는 세계와 출력 방식을 정한다.
01
기준 옵션 선택
프로젝트 성격에 맞춰 strict를 기본으로 두고 예외는 작게 기록한다.
safety baseline
02
모듈 해석
NodeNext, Bundler, path alias가 실제 런타임과 번들러 규칙을
따라가게 맞춘다.
resolution
03
출력 목표
브라우저나 Node 버전에 맞춰 target과 lib를 선택해 polyfill 책임을
분리한다.
runtime target
04
선언 산출물
라이브러리나 모노레포 패키지는 declaration과 composite으로 외부
계약을 남긴다.
public types
strict
초기 비용은 있지만 null, any, 함수 variance 오류를 일찍
잡는다.
기존 코드 전환은 옵션별로 단계화할 수 있다.
마이그레이션 계획
paths
import 경로를 짧게 만들지만 런타임 해석도 함께 설정해야
한다.
tsconfig만 바꾸면 테스트와 번들러가 못 찾을 수 있다.
tool sync
target
낮은 target은 호환성을, 높은 target은 출력 단순성을
준다.
실제 지원 브라우저와 Node 버전을 기준으로 정한다.
runtime truth
tsconfig 변경 전 확인
도구 동기화
Vite, Jest, ESLint, ts-node가 같은 alias와 module 규칙을
쓴다.
출력 위치
outDir이 source와 섞이지 않고 clean 가능하다.
예외 기록
strict 옵션을 끄는 이유와 재검토 시점이 남아 있다.
옵션 축
strict: type safety
moduleResolution: import lookup
target/lib: runtime features
declaration: 공개 계약