Compare commits

...
14 Commits
Author SHA1 Message Date
Emin Khateeb 5a8cf6bbe6 Merge pull request #31 from emin93/react-native-0.59
React Native 0.59 support
2019-03-12 18:24:30 +01:00
Emin Khateeb 8e588cf4b5 Merge branch 'react-native-0.59' of github.com:emin93/react-native-template-typescript into react-native-0.59 2019-03-12 18:21:23 +01:00
Emin Khateeb 5ce07d7e6c minor space addition to prevent comparison issues 2019-03-12 18:21:11 +01:00
Emin Khateeb 33cc106144 Added jest config to ts excludes 2019-03-07 13:19:46 +01:00
Emin Khateeb add36b1f30 Merge pull request #30 from emin93/master
Merge pull request #29 from tallpants/patch-1
2019-03-07 13:18:34 +01:00
Emin Khateeb 2c6b757051 Merge pull request #29 from tallpants/patch-1
Add metro.config.js to tsconfig excluded files
2019-03-07 13:15:34 +01:00
Adithya Reddy 65ac7f1bbf Add metro.config.js to tsconfig excluded files
In the latest RC of React Native (0.59.0-rc.3) a `metro.config.js` file is created with the following content:

```js
/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};
```

When you run `tsc`, it fails with this error:

```
metro.config.js:8:1 - error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided.

8 module.exports = {
  ~~~~~~


Found 1 error.
```

This PR fixes that error by excluding the `metro.config.js` file just like we did for `babel.config.js`.
2019-03-07 11:55:54 +05:30
Emin Khateeb c9184ffc06 added check if package is being installed as a dependency 2019-03-05 12:53:12 +01:00
Emin Khateeb 1bed694429 updated contributing document 2019-03-05 12:36:55 +01:00
Emin Khateeb e2b4039a30 updated license year 2019-03-05 12:34:22 +01:00
Emin Khateeb f8369603f4 reverted package version 2019-03-05 12:23:03 +01:00
Emin Khateeb 2433c22b3d prepared for RN 0.59 release 2019-03-05 12:20:25 +01:00
Emin Khateeb a332cb68f4 Merge pull request #28 from emin93/new-cli-post-install
Prepared automatic execution of the post install script
2019-03-05 10:59:28 +01:00
Emin Khateeb ffc9af3595 Prepared automatic execution of the post install script 2019-02-21 13:31:38 +01:00
11 changed files with 27 additions and 54 deletions

No files matched your search

+1 -1
View File
@@ -48,4 +48,4 @@ const styles = StyleSheet.create({
color: '#333333', color: '#333333',
marginBottom: 5, marginBottom: 5,
}, },
}); });
+1 -7
View File
@@ -1,8 +1,6 @@
# Contributing # Contributing
Cool, I'm glad you decided to contribute to React Native Template TypeScript. Contributing to this project should be as easy and transparent as possible.
Don't worry, I won't bother you with thousands of rules. I want to make contributing to this project as easy and transparent as possible.
## Workflow ## Workflow
@@ -15,7 +13,3 @@ We use [GitHub Flow](https://guides.github.com/introduction/flow/), so all code
## License ## License
By contributing, you agree that your contributions will be licensed under the [MIT License](https://choosealicense.com/licenses/mit/). By contributing, you agree that your contributions will be licensed under the [MIT License](https://choosealicense.com/licenses/mit/).
## Code style
Currently there is no lint configuration, but you should try to stay consistent with the existing code.
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018 Emin Khateeb Copyright (c) 2019 Emin Khateeb
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+6 -15
View File
@@ -13,38 +13,29 @@ Clean and minimalist React Native template for a quick start with TypeScript.
## :arrow_forward: Quick Start ## :arrow_forward: Quick Start
```bash ```bash
react-native init MyApp --template typescript && node MyApp/setup.js react-native init MyApp --template typescript
``` ```
## :question: FAQ ## :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? ### What additional dependencies are included in this template?
- [TypeScript](https://github.com/Microsoft/TypeScript) - [TypeScript](https://github.com/Microsoft/TypeScript)
- [Type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped) - [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. 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. 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? ### How to do type checking?
`npm run tsc` `npx 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)
## :globe_with_meridians: Links ## :globe_with_meridians: Links
+1 -1
View File
@@ -11,4 +11,4 @@ import renderer from 'react-test-renderer';
it('renders correctly', () => { it('renders correctly', () => {
renderer.create(<App />); renderer.create(<App />);
}); });
-1
View File
@@ -3,6 +3,5 @@
"@types/react-native": "latest", "@types/react-native": "latest",
"@types/react-test-renderer": "latest", "@types/react-test-renderer": "latest",
"@types/react": "latest", "@types/react": "latest",
"ts-jest": "latest",
"typescript": "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>"]
}
+2 -1
View File
@@ -4,7 +4,8 @@
"description": "Clean and minimalist React Native template for a quick start with TypeScript.", "description": "Clean and minimalist React Native template for a quick start with TypeScript.",
"scripts": { "scripts": {
"test": "standard setup.js", "test": "standard setup.js",
"prepublishOnly": "npm --no-git-tag-version version $TRAVIS_TAG" "prepublishOnly": "npm --no-git-tag-version version $TRAVIS_TAG",
"install": "node setup.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
+10 -18
View File
@@ -1,25 +1,17 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const packageJson = require('./package.json') if (fs.existsSync(path.join(__dirname, '.travis.yml'))) {
const jestConfig = require('./jest.json') process.exit()
}
const deleteFile = fileName => fs.unlinkSync(path.join(__dirname, fileName)) const projectFilesToDelete = ['.flowconfig', 'App.js', '__tests__/App-test.js']
const writeFile = (fileName, data) => fs.writeFileSync(path.join(__dirname, fileName), data)
console.log('🔄 Setting up...') const templateFilesToDelete = ['setup.js', 'README.md', 'LICENSE']
packageJson.scripts.tsc = 'tsc' const projectPath = path.join(__dirname, '..', '..')
packageJson.jest = Object.assign(packageJson.jest, jestConfig) const deleteProjectFile = fileName => fs.unlinkSync(path.join(projectPath, fileName))
const deleteTemplateFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
writeFile('package.json', JSON.stringify(packageJson, null, 2)) projectFilesToDelete.forEach(deleteProjectFile)
templateFilesToDelete.forEach(deleteTemplateFile)
deleteFile('.flowconfig')
deleteFile('App.js')
deleteFile('__tests__/App.js')
deleteFile('jest.json')
deleteFile('LICENSE')
deleteFile('README.md')
deleteFile('setup.js')
console.log(`✅ Setup completed!`)
+1 -1
View File
@@ -11,5 +11,5 @@
"strict": true, "strict": true,
"target": "esnext" "target": "esnext"
}, },
"exclude": ["node_modules", "babel.config.js"] "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
} }