Bläddra i källkod

configuring typscript

Daniel Zlotin 6 år sedan
förälder
incheckning
3ee6634e71
6 ändrade filer med 62 tillägg och 32 borttagningar
  1. 2
    1
      lib/src/Navigation.js
  2. 0
    20
      lib/src/adapters/Element.js
  3. 28
    0
      lib/src/adapters/Element.tsx
  4. 5
    5
      package.json
  5. 22
    0
      tsconfig-strict.json
  6. 5
    6
      tsconfig.json

+ 2
- 1
lib/src/Navigation.js Visa fil

@@ -8,7 +8,8 @@ const LayoutTreeParser = require('./commands/LayoutTreeParser');
8 8
 const LayoutTreeCrawler = require('./commands/LayoutTreeCrawler');
9 9
 const PrivateEventsListener = require('./events/PrivateEventsListener');
10 10
 const PublicEventsRegistry = require('./events/PublicEventsRegistry');
11
-const Element = require('./adapters/Element');
11
+
12
+import { Element } from './adapters/Element';
12 13
 
13 14
 /** @constructor */
14 15
 class Navigation {

+ 0
- 20
lib/src/adapters/Element.js Visa fil

@@ -1,20 +0,0 @@
1
-import * as React from 'react';
2
-import * as PropTypes from 'prop-types';
3
-import { requireNativeComponent } from 'react-native';
4
-
5
-class Element extends React.Component {
6
-  render() {
7
-    return <RNNElement {...this.props} />;
8
-  }
9
-}
10
-
11
-Element.propTypes = {
12
-  elementId: PropTypes.string.isRequired,
13
-  resizeMode: PropTypes.string
14
-};
15
-Element.defaultProps = {
16
-  resizeMode: ''
17
-};
18
-const RNNElement = requireNativeComponent('RNNElement', Element);
19
-
20
-module.exports = Element;

+ 28
- 0
lib/src/adapters/Element.tsx Visa fil

@@ -0,0 +1,28 @@
1
+import * as React from 'react';
2
+import * as PropTypes from 'prop-types';
3
+import { requireNativeComponent } from 'react-native';
4
+
5
+interface ElementProps {
6
+  elementId: any;
7
+  resizeMode: any;
8
+}
9
+
10
+let RNNElement: React.ComponentClass;
11
+
12
+export class Element extends React.Component<ElementProps, object> {
13
+  static propTypes = {
14
+    elementId: PropTypes.string.isRequired,
15
+    resizeMode: PropTypes.string
16
+  }
17
+  static defaultProps = {
18
+    resizeMode: ''
19
+  }
20
+
21
+  render() {
22
+    return (
23
+      <RNNElement {...this.props} />
24
+    );
25
+  }
26
+}
27
+
28
+RNNElement = requireNativeComponent('RNNElement', Element);

+ 5
- 5
package.json Visa fil

@@ -49,7 +49,8 @@
49 49
   },
50 50
   "dependencies": {
51 51
     "lodash": "4.x.x",
52
-    "prop-types": "15.x.x"
52
+    "prop-types": "15.x.x",
53
+    "tslib": "1.x.x"
53 54
   },
54 55
   "devDependencies": {
55 56
     "detox": "6.x.x",
@@ -57,8 +58,6 @@
57 58
     "eslint-config-xo-react": "0.13.x",
58 59
     "eslint-plugin-react": "7.x.x",
59 60
     "jest": "22.x.x",
60
-    "jsdoc": "3.x.x",
61
-    "jsdoc-to-markdown": "3.x.x",
62 61
     "mocha": "4.x.x",
63 62
     "react": "16.0.0-beta.5",
64 63
     "react-native": "0.49.x",
@@ -72,9 +71,10 @@
72 71
     "typescript": "2.x.x",
73 72
     "@types/react": "16.0.0",
74 73
     "@types/react-native": "0.49.x",
75
-    "@types/jest": "22.x.x",
74
+    "@types/lodash": "4.x.x",
76 75
     "@types/prop-types": "15.x.x",
77
-    "@types/react-test-renderer": "16.0.0"
76
+    "@types/react-test-renderer": "16.0.0",
77
+    "@types/jest": "22.x.x"
78 78
   },
79 79
   "babel": {
80 80
     "env": {

+ 22
- 0
tsconfig-strict.json Visa fil

@@ -0,0 +1,22 @@
1
+{
2
+  "$schema": "http://json.schemastore.org/tsconfig",
3
+  "compilerOptions": {
4
+    "allowSyntheticDefaultImports": false,
5
+    "allowUnreachableCode": false,
6
+    "allowUnusedLabels": false,
7
+    "alwaysStrict": true,
8
+    "diagnostics": true,
9
+    "forceConsistentCasingInFileNames": true,
10
+    "importHelpers": true,
11
+    "noEmitOnError": true,
12
+    "noFallthroughCasesInSwitch": true,
13
+    "noImplicitAny": true,
14
+    "noImplicitReturns": true,
15
+    "noImplicitThis": true,
16
+    "noUnusedLocals": true,
17
+    "noUnusedParameters": true,
18
+    "pretty": true,
19
+    "strictFunctionTypes": false,
20
+    "strictNullChecks": true
21
+  }
22
+}

+ 5
- 6
tsconfig.json Visa fil

@@ -1,18 +1,17 @@
1 1
 {
2
+  "extends": "./tsconfig-strict",
2 3
   "compilerOptions": {
3 4
     "outDir": "./lib/dist",
4 5
     "allowJs": true,
5 6
     "target": "esnext",
6 7
     "module": "commonjs",
7
-    "jsx": "preserve",
8
-    "noEmitOnError": true,
9
-    "noImplicitReturns": true,
10
-    "noFallthroughCasesInSwitch": true,
11
-    "alwaysStrict": true,
12
-    "strictNullChecks": true,
8
+    "jsx": "react-native",
13 9
     "types": [
10
+      "lodash",
14 11
       "react",
15 12
       "react-native",
13
+      "prop-types",
14
+      "react-test-renderer",
16 15
       "jest"
17 16
     ]
18 17
   },