기존 CRA프로젝트에 typescript 템플릿 추가하기

2023. 2. 22. 23:58·React

1. 패키지 설치 

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

 

2. 경로에 있는 js파일 ts, tsx로 확장자 변경해준다.

3. "npx tsc --init" 명령어로 tsconfig.json 파일 생성한 후, tsconfig.json 파일에 "jsx": "react-jsx"추가
4. src/index.tsx에서 수정

const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);

5. 타입이 없다고 나오는 패키지들 타입 추가하기
(패키지를 다운받고 타입이 없는경우는 definitelyTyped 페이지에 왠만한건 다 있을거다)

npm i --save-dev @types/styled-components

 

CRA에서 처음부터 타입스크립트 template 설치하는 법

npx create-react-app 프로젝트이름 --template typescript

 

'React' 카테고리의 다른 글

react-helmet  (0) 2023.02.25
styled-components 전역 스타일링 (Global style)  (0) 2023.02.24
styled-components로 theme적용하기 with Typescript  (0) 2023.02.22
styled-components 기본 문법  (0) 2023.02.22
styled-components, emotion 비교  (0) 2023.02.22
'React' 카테고리의 다른 글
  • react-helmet
  • styled-components 전역 스타일링 (Global style)
  • styled-components로 theme적용하기 with Typescript
  • styled-components 기본 문법
ssund
ssund
  • ssund
    ssund의 기술블로그
    ssund
  • 전체
    오늘
    어제
    • TECH (82)
      • Next.js (8)
      • React (25)
      • Vite (1)
      • javascript (17)
      • CSS (6)
      • CS (10)
      • AWS (0)
      • Jest (1)
      • CI|CD (0)
      • 알고리즘 (8)
      • Tools (1)
      • Tips (5)
  • 블로그 메뉴

    • 링크

    • 공지사항

    • 인기 글

    • 태그

      react state management
      React
      reat-head
      Array.sort()
      JavaScript
      웹브라우저구성
      서버컴포넌트
      theme-provider
      커머스프로젝트
      global-style
      타입스크립트
      git배포
      redux
      call signatures
      TypeScript
      함수와 메서드차이
      배열요소순서
      nextjs
      app-router
      styled-components
    • 최근 댓글

    • 최근 글

    • hELLO· Designed By정상우.v4.10.0
    ssund
    기존 CRA프로젝트에 typescript 템플릿 추가하기
    상단으로

    티스토리툴바