Skip to content

Commit 2433c22

Browse files
committed
prepared for RN 0.59 release
1 parent a332cb6 commit 2433c22

8 files changed

+21
-51
lines changed

App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Generated with the TypeScript template
66
* https://github.com/emin93/react-native-template-typescript
7-
*
7+
*
88
* @format
99
*/
1010

@@ -48,4 +48,4 @@ const styles = StyleSheet.create({
4848
color: '#333333',
4949
marginBottom: 5,
5050
},
51-
});
51+
});

README.md

+6-15
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,30 @@ Clean and minimalist React Native template for a quick start with TypeScript.
1313
## :arrow_forward: Quick Start
1414

1515
```bash
16-
react-native init MyApp --template typescript && node MyApp/setup.js
16+
react-native init MyApp --template typescript
1717
```
1818

1919
## :question: FAQ
2020

21-
### Why this template when React Native 0.57+ supports TypeScript out of the box?
22-
23-
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:
24-
2521
### What additional dependencies are included in this template?
2622

2723
- [TypeScript](https://github.com/Microsoft/TypeScript)
2824
- [Type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped)
29-
- [ts-jest](https://github.com/kulshekhar/ts-jest)
3025

3126
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.
3227

3328
Lots of :heart: and credits to the owners and maintainers of those packages.
3429

35-
### Why the setup script?
36-
37-
It deletes obsolete files like the `.flowconfig` and the `setup.js` itself after the setup.
38-
39-
### How to do type checking?
40-
41-
`npm run tsc`
42-
4330
### Does debugging work?
4431

45-
Yes it does.
32+
Yes it does. :tada:
4633

4734
[![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)
4835

36+
### How to do type checking?
37+
38+
`npx tsc`
39+
4940
## :globe_with_meridians: Links
5041

5142
- ["Using React Native with TypeScript just became simple" on Medium](https://medium.com/@emin93/react-native-typescript-b965059109d3)

__tests__/App.tsx __tests__/App-test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ import renderer from 'react-test-renderer';
1111

1212
it('renders correctly', () => {
1313
renderer.create(<App />);
14-
});
14+
});

devDependencies.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
"@types/react-native": "latest",
44
"@types/react-test-renderer": "latest",
55
"@types/react": "latest",
6-
"ts-jest": "latest",
76
"typescript": "latest"
87
}

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'react-native',
3+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
4+
}

jest.json

-8
This file was deleted.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-template-typescript",
3-
"version": "0.0.1",
3+
"version": "4.1.10",
44
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
55
"scripts": {
66
"test": "standard setup.js",

setup.js

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
const fs = require('fs')
22
const path = require('path')
33

4-
const packageJson = require('./package.json')
5-
const jestConfig = require('./jest.json')
4+
const projectFilesToDelete = ['.flowconfig', 'App.js', '__tests__/App-test.js']
65

7-
if (!packageJson.jest) {
8-
process.exit()
9-
}
6+
const templateFilesToDelete = ['setup.js', 'README.md', 'LICENSE']
107

11-
const deleteFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
12-
const writeFile = (fileName, data) => fs.writeFileSync(path.join(__dirname, fileName), data)
8+
const projectPath = path.join(__dirname, '..', '..')
9+
const deleteProjectFile = fileName => fs.unlinkSync(path.join(projectPath, fileName))
10+
const deleteTemplateFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
1311

14-
console.log('🔄 Setting up...')
15-
16-
packageJson.scripts.tsc = 'tsc'
17-
packageJson.jest = Object.assign(packageJson.jest, jestConfig)
18-
19-
writeFile('package.json', JSON.stringify(packageJson, null, 2))
20-
21-
deleteFile('.flowconfig')
22-
deleteFile('App.js')
23-
deleteFile('__tests__/App.js')
24-
deleteFile('jest.json')
25-
deleteFile('LICENSE')
26-
deleteFile('README.md')
27-
deleteFile('setup.js')
28-
29-
console.log(`✅ Setup completed!`)
12+
projectFilesToDelete.forEach(deleteProjectFile)
13+
templateFilesToDelete.forEach(deleteTemplateFile)

0 commit comments

Comments
 (0)