Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

developer_kcm

tsconfig.json 구성 옵션 본문

Typescript

tsconfig.json 구성 옵션

fullkeem 2024. 6. 10. 14:39

크게 세 가지 옵션으로 구분

1. compilerOptions

2. include

3. exclude

{
  "compilerOptions": {
    // 컴파일된 자바스크립트 버전 설정 (ES5, ES6 등)
    "target": "es6",

    // 모듈 시스템 설정 (CommonJS, ES Modules, esNext 등)
    "module": "exNext", // ECMAScript의 가장 최신 버전
    
    // 모듈 해석에 사용할 기준 경로 지정
    "baseUrl": "./",
    
    // 컴파일러가 참조할 타입 선언(d.ts)의 경로를 지정
    "typeRoots": ["./node_modules/@types"],
    
    // 컴파일에서 사용할 라이브러리 지정 - "ESNext", "DOM"
    "lib": ["ESNext", "DOM"],

    // 컴파일된 파일 출력 디렉토리 설정
    "outDir": "./dist",

    // 소스맵 생성 여부 설정 (디버깅에 유용)
    "sourceMap": true,

    // 엄격한 타입 검사 활성화 여부
    "strict": true,

    // "any" 타입을 암묵적으로 허용하지 않음 (타입 안정성 강화)
    "noImplicitAny": true,

    // import 문에 파일 확장자 생략 허용 여부
    "allowJs": false,

    // CommonJS와 ES Modules 간의 상호 운용성을 위한 설정
    "esModuleInterop": true,

    // 선언 파일(.d.ts) 생성 여부
    "declaration": true,

    // 선언 파일 출력 디렉토리 설정 (declaration이 true일 때 유효)
    "declarationDir": "./types",

    // 실험적인 데코레이터 기능 활성화 여부
    "experimentalDecorators": true,

    // strict 모드에서 null 체크 강화
    "strictNullChecks": true,

    // 모듈 해석 방식 설정 (Classic, Node)
    "moduleResolution": "node", 
    
    // 모든 파일을 모듈로 컴파일, import 혹은 export 키워드 필수
    "isolatedModules" : true,
  },

  // 컴파일할 파일 목록 (glob 패턴 사용)
  "include": ["src/**/*"],

  // 컴파일에서 제외할 파일 목록 (glob 패턴 사용)
  "exclude": ["node_modules", "**/*.spec.ts"]
}