typescript 설치하기
JavaScript With Syntax For Types.
npm을 설치
NPM : Node Package Manager
NPm을 설치하기 위해서는 Node.js를 설치해야 한다.
Node.js란?
브라우저 밖에서 자바스크립트를 실행할 수 있는 runtime 환경
Node.js 설치 후 TypeScript를 설치해준다.
npm install -g typescript
이제 컴파일러를 다운 했기 때문에 tsc 명령어를 사용해서 타입스크립트를 자바스크립트로 변환 가능하다.
app.ts → 코드를 입력한다.
ts이다.컴파일 한다.
tsc app.ts
이제 js를 run한다.
node app.js
자동으로 ts파일을 js 파일로 근처에 변환
tsc -w
npm install --save typescript @types/node @types/react @types/react-dom @types/jestnpx create-react-app my-app --template typescriptDuplicate function implementation.ts 에러 메시지가 뜬다면?
typescript configuration 파일을 추가해준다.
tsc --init
타입스크립트 파일 내에 변동 사항이 생길 때마다 자바스크립트에도 업데이트 해준다.
tsc -w app.tx
tsc