03. 데이터 타입, tsc watch - seongjunhwang/clone_blockchain GitHub Wiki

인자 타입 설정

  • 인자 뒤에 :데이터타입 입력

함수 타입 설정

  • 함수 뒤에 :데이터타입 입력
const sayHi = (name: string, age: number, gender: string): string => {
    return (`hello ${name}, you are ${age}, you are ${gender}`)
};

서버 자동 재시작

  • TSC Watch 설치
    • yarn tsc-watch --dev
  • package.json 파일 수정
  "scripts": {
    "start": "tsc-watch --onSuccess \" node dist/index.js\" "
  },
  • tsconfig.json 파일 수정
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES2015",
        "sourceMap": true,
        "outDir": "dist"
    },
    "include": ["src/**/*"],
    "exclude": ["node_modules"]
}
  • src폴더에 ts파일, dist폴더에 js파일 생성되도록 세팅