성격 급한 한국인을 위한 CRA + (TS)

TigerStoneV·2022년 11월 17일
0
post-thumbnail

생성

  • 빈 폴더 하나 생성.
  • node,npm,npx 설치 유무 확인.
    • 안되어 있으면 lts 버전으로 설치 및 필요 버전으로 설치.
// terminal
$ npx create-react-app "project name" —-template typescript
// typescript에 대한 필요 설치.
$ npm i --save react react-dom typescript
$ npm i --save-dev @types/react @types/react-dom @types/node

거의 끝났다.

  • 설치가 완료 되면 tsconfig 및 app.tsx를 확인할 수 있다.
// 실행
$ npm start

빠르게 기존 CRA/js -> CRA/ts 변경방법.

//terminal
// 생성
$ npx create-react-app [project name]
$ cd [project name]

// 라이브러리 설치
$ npm install --save typescript @types/node @types/react @types/react-dom @types/jest

//기존 tsconfig 파일 수정.
// App.jsx -> App.tsx 등으로 확장자 변환.

추가적 오류는 TypeError

에러는 계속해서 나오고 CRA 생성은 기본입니다.
js->ts 방식보다는 처음부터 ts로 만드는 방법이 좋을수도 있으며 개인적으로는 그렇게 작성합니다

profile
개발 삽질하는 돌호랑이

0개의 댓글