My Study/React
[React, TypeScript] - React에 TypeScript 추가하기
handbefore
2024. 10. 14. 15:24
React 프로젝트가 TypeScript 사용하도록 설정해야 함.
Create-React-App(CRA) 사용.
1. create react app 검색
2. 'Create React App Docs' 문서 페이지
https://create-react-app.dev/docs/getting-started/
Getting Started | Create React App
Create React App is an officially supported way to create single-page React
create-react-app.dev
Create-React-App 사용법, 타입스크립트와 통합하는 방법 ... 등등
3. Building your App(앱 빌드) 선택 -> Adding TypeScript
https://create-react-app.dev/docs/adding-typescript
Adding TypeScript | Create React App
Note: this feature is available with react-scripts@2.1.0 and higher.
create-react-app.dev
-타입스크립트 기반 프로젝트로 생성
npx create-react-app 프로젝트명 --template typescript
- 기존 폴더에 프로젝트 생성됨(하위 폴더).
- 확장자 .tsx 사용.
- 최적화 단계는 별도로 제공(자동적 수행)
- @types 패키지: 번역기 역할