prepared for RN 0.59 release

This commit is contained in:
Emin Khateeb committed 2019-03-05 12:20:25 +01:00
1 parent a332cb68f4
commit 2433c22b3d
8 files changed
+21 -51

No files matched your search

+2 -2
View File
@@ -4,7 +4,7 @@
*
* Generated with the TypeScript template
* https://github.com/emin93/react-native-template-typescript
*
*
* @format
*/
@@ -48,4 +48,4 @@ const styles = StyleSheet.create({
color: '#333333',
marginBottom: 5,
},
});
});
+6 -15
View File
@@ -13,38 +13,29 @@ Clean and minimalist React Native template for a quick start with TypeScript.
## :arrow_forward: Quick Start
```bash
react-native init MyApp --template typescript && node MyApp/setup.js
react-native init MyApp --template typescript
```
## :question: FAQ
### Why this template when React Native 0.57+ supports TypeScript out of the box?
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.
Lots of :heart: and credits to the owners and maintainers of those packages.
### Why the setup script?
### Does debugging work?
It deletes obsolete files like the `.flowconfig` and the `setup.js` itself after the setup.
Yes it does. :tada:
[![Demonstration of working breakpoints in Visual Studio Code](https://cdn-images-1.medium.com/max/1600/1*ZXfzgq1xKz1B3chYy9xE7w.png)](https://medium.com/@emin93/react-native-typescript-b965059109d3)
### How to do type checking?
`npm run tsc`
### Does debugging work?
Yes it does.
[![Demonstration of working breakpoints in Visual Studio Code](https://cdn-images-1.medium.com/max/1600/1*ZXfzgq1xKz1B3chYy9xE7w.png)](https://medium.com/@emin93/react-native-typescript-b965059109d3)
`npx tsc`
## :globe_with_meridians: Links
+1 -1
View File
@@ -11,4 +11,4 @@ import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});
});
-1
View File
@@ -3,6 +3,5 @@
"@types/react-native": "latest",
"@types/react-test-renderer": "latest",
"@types/react": "latest",
"ts-jest": "latest",
"typescript": "latest"
}
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
-8
View File
@@ -1,8 +0,0 @@
{
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"modulePaths": ["<rootDir>"]
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-native-template-typescript",
"version": "0.0.1",
"version": "4.1.10",
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
"scripts": {
"test": "standard setup.js",
+7 -23
View File
@@ -1,29 +1,13 @@
const fs = require('fs')
const path = require('path')
const packageJson = require('./package.json')
const jestConfig = require('./jest.json')
const projectFilesToDelete = ['.flowconfig', 'App.js', '__tests__/App-test.js']
if (!packageJson.jest) {
process.exit()
}
const templateFilesToDelete = ['setup.js', 'README.md', 'LICENSE']
const deleteFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
const writeFile = (fileName, data) => fs.writeFileSync(path.join(__dirname, fileName), data)
const projectPath = path.join(__dirname, '..', '..')
const deleteProjectFile = fileName => fs.unlinkSync(path.join(projectPath, fileName))
const deleteTemplateFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
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('jest.json')
deleteFile('LICENSE')
deleteFile('README.md')
deleteFile('setup.js')
console.log(`✅ Setup completed!`)
projectFilesToDelete.forEach(deleteProjectFile)
templateFilesToDelete.forEach(deleteTemplateFile)