setup typescript better

This commit is contained in:
Jake Howard 2016-09-16 14:41:18 +01:00
parent 62bc623c12
commit 79839b08a3
Signed by: jake
GPG key ID: 57AFB45680EDD477
6 changed files with 86 additions and 109 deletions

View file

@ -1,53 +1,14 @@
/** import React from 'react';
* Sample React Native App import { AppRegistry } from 'react-native';
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react'; import App from './dist/index';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
class zxcvbn extends Component { class MainApp extends React.Component {
render() { render() {
return ( return (
<View style={styles.container}> <App />
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button for dev menu
</Text>
</View>
); );
} }
} }
const styles = StyleSheet.create({ AppRegistry.registerComponent('zxcvbn', () => MainApp);
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('zxcvbn', () => zxcvbn);

View file

@ -1,53 +1,14 @@
/** import React from 'react';
* Sample React Native App import { AppRegistry } from 'react-native';
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react'; import App from './dist/index';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
class zxcvbn extends Component { class MainApp extends React.Component {
render() { render() {
return ( return (
<View style={styles.container}> <App />
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
); );
} }
} }
const styles = StyleSheet.create({ AppRegistry.registerComponent('zxcvbn', () => MainApp);
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('zxcvbn', () => zxcvbn);

View file

@ -4,15 +4,18 @@
"private": true, "private": true,
"scripts": { "scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start", "start": "node node_modules/react-native/local-cli/cli.js start",
"build": "tsc" "build": "rm -rf build && tsc"
}, },
"dependencies": { "dependencies": {
"immutable": "=3.8.1", "immutable": "=3.8.1",
"react": "=15.3.1", "react": "=15.3.1",
"react-native": "=0.33.0", "react-native": "=0.33.0",
"react-native-progress-bar": "=0.1.2", "react-native-progress-bar": "=0.1.2",
"typescript": "^1.8.10", "typescript": "=1.8.10",
"underscore": "=1.8.3", "underscore": "=1.8.3",
"zxcvbn": "=4.3.0" "zxcvbn": "=4.3.0"
},
"devDependencies": {
"tslint": "^3.15.1"
} }
} }

43
src/index.tsx Normal file
View file

@ -0,0 +1,43 @@
// src/index.ts
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
interface Props {
}
interface State {
}
export default class App extends Component<Props, State> {
render() {
return (
<View style={styles.container}>
<Text style={styles.text}>
Welcome to React Native!
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
} as React.ViewStyle,
text: {
fontSize: 20,
textAlign: 'center',
margin: 10,
} as React.TextStyle,
});

View file

@ -1,19 +1,27 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6", "target": "es2015",
"allowJs": true, "module": "es2015",
"jsx": "react", "jsx": "react",
"outDir": "dist", "outDir": "dist",
"rootDir": "src", "rootDir": "src",
"sourceMap": true, "allowSyntheticDefaultImports": true,
"noImplicitAny": false "noImplicitAny": true,
}, "experimentalDecorators": true,
"filesGlob": [ "preserveConstEnums": true,
"typings/**/*.d.ts", "allowJs": true,
"src/**/*.ts", "sourceMap": true
"src/**/*.tsx" },
], "filesGlob": [
"exclude": [ "typings/index.d.ts",
"node_modules" "src/**/*.ts",
] "src/**/*.tsx"
],
"exclude": [
"index.android.js",
"index.ios.js",
"dist",
"node_modules"
],
"compileOnSave": false
} }

View file

@ -4,6 +4,7 @@
"immutable": "registry:npm/immutable#3.7.6+20160411060006" "immutable": "registry:npm/immutable#3.7.6+20160411060006"
}, },
"globalDependencies": { "globalDependencies": {
"react": "registry:dt/react#0.14.0+20160829191040",
"react-native": "registry:dt/react-native#0.29.0+20160830141535" "react-native": "registry:dt/react-native#0.29.0+20160830141535"
} }
} }