# Node.js 프로젝트 초기화
> npm init (프로젝트 명, 버전 등 프로젝트 정보 입력)
또는
> npm init -y (프로젝트 정보를 기본값으로 설정)
# Typescript 모듈 설치
> npm install typescript (현재 프로젝트 경로에 Typescript 모듈 설치)
또는
> npm install typescript -g (전역 경로에 Typescript 모듈 설치, 어떤 경로에서든 Typescript 컴파일 가능)
# tsconfig.json 파일 생성
> tsc --init
또는
> npx tsc --init (전역 경로에 Typescript 모듈을 설치하지 않은 경우)
tsconfig.json
파일이 생성되었다면 프로젝트에 맞게 Typescript 설정을 적용합니다.{
"compileOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "dist",
"skipLibCheck": true,
"strict": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
compileOptions
: Typescript 컴파일 시 적용되는 설정
compileOptions.target
: 타겟 JS 버전
compileOptions.module
: 모듈 방식
compileOptions.outDir
: Typescript 컴파일 후 결과물 저장 경로 (.js 파일)
compileOptions.skipLibCheck
: Library 파일 검사를 스킵하여 컴파일 시간 절약
compileOptions.strict
: 광범위한 유형 검사 동작 활성화 여부
include
: 컴파일 시 포함될 파일 또는 경로
exclude
: 컴파일 시 제외할 파일 또는 경로