React JS를 TS로 변환하기

Kim Nahyeong·2022년 4월 1일
0

GDSC

목록 보기
3/3

이미 존재하는 React JS로 만들어진 프로젝트를 TS로 변환시켜보자.

1

npm install --save typescript @types/node @types/react @types/react-dom @types/jest
yarn add typescript @types/node @types/react @types/react-dom @types/jest

를 입력해서 기존 프로젝트에 TypeScript를 추가한다.

2

npx tsc --init

를 입력해 typeScript 기본 환경 설정인 tsconfig.json 을 만든다.

3

프로젝트의 js 패키지를 ts 패키지로 재설치 해줘야한다.
예를 들어 react-router-dom이 설치되어있다면 @types/react-router-dom를 설치해야한다.

4

이제 js 파일을 ts로 변환시켜주면 된다. 끝!

0개의 댓글