Compare commits

..
10 Commits
8 changed files with 53 additions and 21 deletions

No files matched your search

+5 -6
View File
@@ -17,21 +17,20 @@ node setup.js
### What is included in this template?
- [TypeScript](https://github.com/Microsoft/TypeScript)
- [TypeScript type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped)
- [React Native Typescript Transformer](https://github.com/ds300/react-native-typescript-transformer)
- [React Native TypeScript transformer](https://github.com/ds300/react-native-typescript-transformer)
- [Type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped)
- [TS Jest](https://github.com/kulshekhar/ts-jest)
- [TSLint](https://github.com/palantir/tslint)
- [TSLint React](https://github.com/palantir/tslint-react)
This template always uses the latest versions of the dependencies at the time when the setup script (`node setup.js`) 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?
The React Native CLI supports automatic installation of production dependencies only. Since TypeScript and the other dependencies are dev dependencies, the setup script is being used to install those. It also takes care of obsolete files like the `.flowconfig` and the `setup.js` itself after the setup.
### What about Jest?
This template does not cover Jest yet. For more info on the current status check the [open issue](https://github.com/emin93/react-native-template-typescript/issues/1).
### How will this template affect the React Native CLI workflow?
The React Native CLI will do everything just as without a template and afterwards overwrite the files with the ones from this template. This means you don't have to worry about incompatibility issues with later React Native upgrades.
+9
View File
@@ -0,0 +1,9 @@
import * as React from "react";
import "react-native";
import { create } from "react-test-renderer";
import App from "../src/App";
it("renders correctly", () => {
const tree = create(<App exampleProp="helloWorld" />);
});
+3 -1
View File
@@ -2,7 +2,9 @@
"typescript",
"tslint",
"tslint-react",
"react-native-typescript-transformer",
"ts-jest",
"@types/react",
"@types/react-native",
"react-native-typescript-transformer"
"@types/jest"
]
+1 -1
View File
@@ -1,4 +1,4 @@
import { AppRegistry } from 'react-native';
import App from './lib/App';
import App from './src/App';
AppRegistry.registerComponent('HelloWorld', () => App);
+15
View File
@@ -0,0 +1,15 @@
{
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"modulePaths": ["<rootDir>"]
}
+4 -3
View File
@@ -10,10 +10,11 @@
"url": "git+https://github.com/emin93/react-native-template-typescript.git"
},
"keywords": [
"react",
"native",
"template",
"react-native",
"typescript",
"tslint",
"jest",
"template",
"boilerplate"
],
"author": "Emin Khateeb <emin@emin.ch>",
+7 -1
View File
@@ -3,20 +3,26 @@ const path = require('path');
const { execSync } = require('child_process');
const packageJson = require('./package.json');
const jestJson = require('./jest.json');
const devDependencies = require('./devDependencies.json');
const deleteFile = (fileName) => fs.unlinkSync(path.join(process.cwd(), fileName));
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), fileName), data);
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js')}`;
console.log('🔄 Please wait...');
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js`;
packageJson.scripts.lint = 'tslint -c tslint.json "src/**/*.{ts,tsx}"';
packageJson.jest = Object.assign(packageJson.jest, jestJson);
writeFile('package.json', JSON.stringify(packageJson, null, 2));
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`);
deleteFile('App.js');
deleteFile('__tests__/App.js');
deleteFile('.flowconfig');
deleteFile('devDependencies.json');
deleteFile('jest.json');
deleteFile('README.md');
deleteFile('LICENSE');
deleteFile('setup.js');
+9 -9
View File
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"noEmit": true,
"moduleResolution": "node",
},
"exclude": [
"node_modules"
]
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"noEmit": true,
"moduleResolution": "node",
},
"exclude": [
"node_modules"
]
}