1. 새로운 React TypeScript 프로젝트 만들기
npx create-react-app [프로젝트 명] --template typescript
or
yarn create react-app [프로젝트 명] --template typescript
1-1. 이미 만들어진 프로젝트에 TypeScript 적용하고 싶다면?
1. 타입 정의 파일 다운
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
# or
yarn add typescript @types/node @types/react @types/react-dom @types/jest
2. Typescript 코드 작성을 위한 typescript 패키지 설치
npm install --save-dev typescript
3. typescript 설정파일 생성
npx typescript --init
✨ 2. VScode에서 해당 프로젝트 열기
1. 터미널에서 해당 프로젝트 경로로 이동
2. 해당 경로에서 code . 을 입력하면 생성한 프로젝트가 열린다.
$ code .
📝 참고
VScode는 tsconfig.json을 참고해서 타입스크립트 문법을 검사한다.
또한, 웹팩에서 설정한 ts-loader가 이 파일을 참고해서 트랜스 파일 작업을 하기 때문에 tsconfig.json 파일을 먼저 생성해야 한다.
댓글