TypeScript 설치 및 사용
node.js 설치
node version manager -nvm
타입스크립트 컴파일러 설치
1. npm으로 설치(권장)
npm i typescript -g
node_modules/.bin/tsc
tsc souce.ts(컴파일러 명령어 tsc + 파일명.ts)
2. visual studio plugin 설치(디폴트로 설치되어 있음)
npm으로 global 모드로 설치
npm i typescript -g
tsc 설정파일 설정
tsc --init --> tsconfig.json
tsc -w(watch모드)
터미널 하나 더 킨 후 nano test.ts(자동으로 js파일로 컴파일됨)
프로젝트 모드로 tsc설정
npm uninstall typescript -g(글로벌로 설치한거 삭제)
mkdir tsc-project
npm init -y ---> package.json생성
npm i typescript
tsc 실행방법
1번째 방법) node_modules/.bin/tsc
2번째 방법) node_modules/typescript/bin/tsc
3번째 방법) npx tsc (npx tsc --init해서 tsconfig.json생성해줘야)
$ nano package.json
test부분 다 지우고 "build": "tsc"
npm run build (tsc실행됨)
VS Code 설치 및 설정
터미널
npm init -y
npm i typescript -D
커맨드 팔레트 - select typescript version-user workspace version
First Type Annotation
let a: string; (a의 데이터 타입 지정)
function hello(b: number) {
}