TYPESCRIPT
create react app typescript
npx create-react-app app-name --template typescript
# or using yarn
yarn create react-app app-name --template typescript
react typescript create react app
npx create-react-app app-name --template typescript
// or using yarn
yarn create react-app app-name --template typescript
add typescript to react-native
yarn add -D typescript @types/jest @types/react @types/react-native @types/react-test-renderer
create react app with typescript
yarn create react-app my-app --template typescript
react-native use typescript
yarn add --dev typescript @types/jest @types/react @types/react-native @types/react-test-renderer
# or for npm
npm install --save-dev typescript @types/jest @types/react @types/react-native @types/react-test-renderer
react-native use typescript
module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
};
react-native use typescript
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es6"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules",
"babel.config.js",
"metro.config.js",
"jest.config.js"
]
}
add typescript to react-native
module.exports = { preset: 'react-native', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']};