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

2023. 2. 22. 23:58·NOTE

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

 

'NOTE' 카테고리의 다른 글

Array.findIndex()  (0) 2023.03.02
react-helmet  (0) 2023.02.25
Array.prototype.filter(), Array.prototype.find()의 차이  (0) 2023.02.16
Swiper.js slidesPerGroup 슬라이드 여러장씩 이동시키기  (0) 2023.02.03
a태그 이미지 다운로드 구현  (0) 2022.03.20
'NOTE' 카테고리의 다른 글
  • Array.findIndex()
  • react-helmet
  • Array.prototype.filter(), Array.prototype.find()의 차이
  • Swiper.js slidesPerGroup 슬라이드 여러장씩 이동시키기
ssund
ssund
  • ssund
    ssund의 기술블로그
    ssund
  • 전체
    오늘
    어제
    • 분류 전체보기 (73)
      • TECH (22)
      • NOTE (40)
      • DAILY (7)
      • javascript (1)
      • 알고리즘 (0)
  • 블로그 메뉴

    • 홈
    • TECH
    • NOTE
    • DAILY
  • 링크

  • 공지사항

  • 인기 글

  • 태그

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

  • 최근 글

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

티스토리툴바