📚 프론트엔드 공부 일지/TYPESCRIPT

타입스크립트 개발 환경 구성하기

wei3on 2024. 8. 14. 13:53

 

설치해야할 것들

nodejs, npm 

 

npm install -g typescript

 

tsc main.ts

 

tsc main.ts -w

 

tsconfig.json을 루트 경로에 생성한다.

{
  "compilerOptions": {
    "rootDir": "./src", //src 폴더 안에서 루트파일
    "outDir": "./build/js" // 어디로 컴파일되서 들어가게 할건지
  }
}

 

{
  "compilerOptions": {
    "rootDir":"./src",
    "outDir":"./build/js",
    "target":"ES6" //ES6 문법으로 컴파일링
  }
}

기타 다른 컴파일 옵션들 💬

{
  "compilerOptions": {
    "rootDir":"./src",
    "outDir":"./build/js",
    "target":"ES6",
    "noEmitOnError":false //에러가 있을 때는 컴파일 하지 않음
    "module":"ESNext",
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "lib":["ESNext", "DOM"], //컴파일 과정에서 사용하는 라이브러리
    "strict":true,
  },
  "include":[
    "./src/**/*.ts", //src 폴더 안에 있는 ts 파일만 인식
  ]
}

 

'📚 프론트엔드 공부 일지 > TYPESCRIPT' 카테고리의 다른 글

Type annotation, Type inference  (0) 2024.08.12
Typescript / Typescript Type  (0) 2024.07.25