Add support for typescript
authorFrank Bessou <frank.bessou@logilab.fr>
Thu, 06 Jul 2017 10:13:42 +0200
changeset 252 6742e5af0acb
parent 251 5e20ac53b497
child 253 22f11f2c300d
Add support for typescript Add tsconfig, tslint and packages and their configuration. All files ending in '.ts' or '.tsx' are transpiled by the typescript compiler to es6 which is then transpiled to es5 by babel.
package.json
tsconfig.json
tslint.json
webpack/common.config.js
--- a/package.json	Tue Jul 04 12:26:39 2017 +0200
+++ b/package.json	Thu Jul 06 10:13:42 2017 +0200
@@ -18,6 +18,7 @@
     "whatwg-fetch": "^0.11.0"
   },
   "devDependencies": {
+    "awesome-typescript-loader": "^3.1.3",
     "babel": "^6.5.2",
     "babel-loader": "^6.2.4",
     "babel-polyfill": "^6.7.4",
@@ -59,6 +60,8 @@
     "script-loader": "^0.7.0",
     "sinon": "^2.1.0",
     "style-loader": "^0.18.2",
+    "tslint": "^5.2.0",
+    "typescript": "^2.3.2",
     "url-loader": "^0.5.9",
     "webpack": "^2.3.1",
     "webpack-dev-server": "^2.4.2"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsconfig.json	Thu Jul 06 10:13:42 2017 +0200
@@ -0,0 +1,13 @@
+{
+    "compilerOptions": {
+        "target": "es6",
+        "module": "es6",
+        "sourceMap": true,
+        "allowJs": true,
+        "strict": true
+    },
+    "include": [
+        "src/**/*"
+    ]
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tslint.json	Thu Jul 06 10:13:42 2017 +0200
@@ -0,0 +1,43 @@
+{
+    "defaultSeverity": "error",
+    "extends": [
+        "tslint:recommended"
+    ],
+    "jsRules": {},
+    "rules": {
+        "object-literal-key-quotes": [true, "as-needed"],
+        "curly": true,
+        "interface-name": [false, "never-prefix"],
+        "max-classes-per-file": false,
+        "no-console": [true, "log"],
+        "no-consecutive-blank-lines": true,
+        "no-unused-variable": true,
+        "no-use-before-declare": true,
+        "no-var-keyword": true,
+        "no-var-requires": true,
+        "one-line": [
+            true,
+            "check-catch",
+            "check-finally",
+            "check-else",
+            "check-open-brace",
+            "check-whitespace"
+        ],
+        "quotemark": [true, "single", "avoid-escape"],
+        "radix": true,
+        "semicolon": [true, "always","ignore-bound-class-methods"],
+        "no-string-literal": false,
+        "whitespace": [
+            true,
+            "check-branch",
+            "check-decl",
+            "check-operator",
+            "check-module",
+            "check-separator",
+            "check-type",
+            "check-typecast",
+            "check-preblock"
+        ]
+    },
+    "rulesDirectory": []
+}
--- a/webpack/common.config.js	Tue Jul 04 12:26:39 2017 +0200
+++ b/webpack/common.config.js	Thu Jul 06 10:13:42 2017 +0200
@@ -5,6 +5,9 @@
 const webpack = require('webpack');
 
 module.exports = {
+    resolve: {
+        extensions: ['.js', '.jsx', '.ts', '.tsx'],
+    },
     entry: [path.join(paths.source, 'index.js')],
     output: {
         filename: 'react-jsonschema-ui.js',
@@ -22,6 +25,19 @@
                 },
             },
             {
+                test: /\.tsx?$/,
+                exclude: /node_modules/,
+                use: [
+                    "babel-loader",
+                    {
+                        loader: "awesome-typescript-loader",
+                        options: {
+                            configFileName: path.resolve(__dirname, '..', 'tsconfig.json'),
+                        },
+                    },
+                ],
+            },
+            {
                 test: /\.css$/,
                 loader: "style-loader!css-loader",
             },