우선 TypeScript에 필수적인 라이브러리 설치 진행
처음 만들어둔 프로젝트에서 typeScript 라이브러리를 설치한다.
npm install typescript @types/react @types/react-native --save-dev
총 세개의 라이브러리를 설치한다.
- typescript : TypeScript 코드 작성을 위한 패키지
- @types/react: react에서 사용할 타입이 정의된 패키지
- @types/react-native: react-native에서 사용할 타입이 정의된 패키지
TypeScript 설정 파일 만들기
처음 폴더에서 tsconfig.json 파일을 생성 아래 내용을 복사하여 저장한다.

위 처럼 root 폴더 내에서 tsconfig.json을 만든다.
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6", "es2017"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext",
"skipLibCheck": true
},
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}
그리고 위의 내용을 작성한뒤 저장한다. 이러면 이제 typeScript 작성이 가능해진다.
'핸드메이드 프로그램 > 실시간 코인가격 알림 ( React native )' 카테고리의 다른 글
TypeScript 제네릭 (0) | 2021.08.10 |
---|---|
TypeScript 함수 작성 (0) | 2021.08.09 |
'decorators-legacy' isn't currently enabled 오류 해결 (0) | 2021.07.26 |
기본적인 화면 구성 (0) | 2021.07.26 |
React-native 설치 및 세팅 (0) | 2021.07.24 |
댓글