Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
100447b7d5 | ||
|
|
4fc8174c3f | ||
|
|
ffcf32376d | ||
|
|
9e7a6483bb | ||
|
|
44e7ad381c | ||
|
|
9da8429132 | ||
|
|
371438e4e2 | ||
|
|
3c0fb203c8 | ||
|
|
be099fa8ce | ||
|
|
ad5174f050 |
No files matched your search
@@ -20,12 +20,13 @@ react-native init MyApp --template typescript && node MyApp/setup.js
|
||||
|
||||
### Why this template when React Native 0.57+ supports TypeScript out of the box?
|
||||
|
||||
First of all, I started this template before React Native 0.57 came out. After React Native 0.57 was announced, I planned to stop maintenance on this template. But after further evaluation, there's still some manual work to do (add type definitions for React & React Native, create a `.tsconfig` for type checking, etc.) to properly set up a React Native 0.57+ TypeScript project. And that's where this template comes in and does that work for you. :raised_hands:
|
||||
Actually, when React Native 0.57 was announced, I planned to stop maintenance on this template. But after further evaluation, there's still quite a lot of manual work to do (add type definitions for React & React Native, create a `.tsconfig` for type checking, etc.) to properly set up a React Native 0.57+ TypeScript project. And that's where this template comes in and does that work for you. :raised_hands:
|
||||
|
||||
### What additional dependencies are included in this template?
|
||||
|
||||
- [TypeScript](https://github.com/Microsoft/TypeScript)
|
||||
- [Type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped)
|
||||
- [ts-jest](https://github.com/kulshekhar/ts-jest)
|
||||
|
||||
This template always uses the latest versions of the dependencies at the time when the `react-native init` command is being executed. This means you don't have to worry about old versions.
|
||||
|
||||
@@ -49,6 +50,7 @@ Yes it does.
|
||||
|
||||
- ["Using React Native with TypeScript just became simple" on Medium](https://medium.com/@emin93/react-native-typescript-b965059109d3)
|
||||
- ["24 tips for React Native you probably want to know" on Albert Gao's blog](http://albertgao.xyz/2018/05/30/24-tips-for-react-native-you-probably-want-to-know/#9-For-Typescript)
|
||||
- ["3 Easy Steps to Set Up React Native with TypeScript, Jest and Enzyme" on Medium by Jan Hesters](https://medium.com/@jan.hesters/3-easy-steps-to-set-up-react-native-with-typescript-jest-and-enzyme-592ca042262f)
|
||||
|
||||
## :computer: Contributing
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
import 'react-native';
|
||||
import React from 'react';
|
||||
import App from '../App';
|
||||
|
||||
// Note: test renderer must be required after react-native.
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
renderer.create(<App />);
|
||||
});
|
||||
@@ -3,5 +3,6 @@
|
||||
"@types/react-native": "latest",
|
||||
"@types/react-test-renderer": "latest",
|
||||
"@types/react": "latest",
|
||||
"ts-jest": "latest",
|
||||
"typescript": "latest"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": "ts-jest"
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
|
||||
"modulePaths": ["<rootDir>"]
|
||||
}
|
||||
Generated
+361
-614
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -4,7 +4,7 @@
|
||||
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
|
||||
"scripts": {
|
||||
"test": "standard setup.js",
|
||||
"prepublishOnly": "git reset --hard && npm --no-git-tag-version version from-git"
|
||||
"prepublishOnly": "npm --no-git-tag-version version $TRAVIS_TAG"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,6 +24,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/emin93/react-native-template-typescript#readme",
|
||||
"devDependencies": {
|
||||
"standard": "11.0.1"
|
||||
"standard": "12.0.1"
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const packageJson = require('./package.json')
|
||||
const jestConfig = require('./jest.json')
|
||||
|
||||
const deleteFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
|
||||
const writeFile = (fileName, data) => fs.writeFileSync(path.join(__dirname, fileName), data)
|
||||
@@ -9,11 +10,13 @@ const writeFile = (fileName, data) => fs.writeFileSync(path.join(__dirname, file
|
||||
console.log('🔄 Setting up...')
|
||||
|
||||
packageJson.scripts.tsc = 'tsc'
|
||||
packageJson.jest = Object.assign(packageJson.jest, jestConfig)
|
||||
|
||||
writeFile('package.json', JSON.stringify(packageJson, null, 2))
|
||||
|
||||
deleteFile('.flowconfig')
|
||||
deleteFile('App.js')
|
||||
deleteFile('__tests__/App.js')
|
||||
deleteFile('LICENSE')
|
||||
deleteFile('README.md')
|
||||
deleteFile('setup.js')
|
||||
|
||||
+2
-2
@@ -4,12 +4,12 @@
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-native",
|
||||
"jsx": "react",
|
||||
"lib": ["es6"],
|
||||
"moduleResolution": "node",
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"target": "esnext"
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["node_modules", "babel.config.js"]
|
||||
}
|
||||
Reference in new issue
Block a user