THRIFT-5811: Update eslint & prettier
Client: js
Patch: Cameron Martin

This closes #3087
diff --git a/lib/ts/Gruntfile.js b/lib/ts/Gruntfile.js
index 61ab582..3e4b1c4 100644
--- a/lib/ts/Gruntfile.js
+++ b/lib/ts/Gruntfile.js
@@ -5,55 +5,57 @@
 // Grunt Setup -  npm install  //reads the ./package.json and installs project dependencies
 // Run grunt -    npx grunt  // uses project-local installed version of grunt (from package.json)
 
-module.exports = function(grunt) {
-  'use strict';
+module.exports = function (grunt) {
+  "use strict";
 
   grunt.initConfig({
-    pkg: grunt.file.readJSON('package.json'),
+    pkg: grunt.file.readJSON("package.json"),
     concat: {
       options: {
-        separator: ';'
+        separator: ";",
       },
       dist: {
-        src: ['src/**/*.js'],
-        dest: 'dist/<%= pkg.name %>.js'
-      }
+        src: ["src/**/*.js"],
+        dest: "dist/<%= pkg.name %>.js",
+      },
     },
     shell: {
       InstallThriftJS: {
-        command: 'mkdir -p test/build/ts/lib; cp ../js/src/thrift.js test/build/ts/thrift.js'
+        command:
+          "mkdir -p test/build/ts/lib; cp ../js/src/thrift.js test/build/ts/thrift.js",
       },
       InstallThriftNodeJSDep: {
-        command: 'cd ../..; npm install'
+        command: "cd ../..; npm install",
       },
       InstallTestLibs: {
-        command: 'cd test; ant download_jslibs'
+        command: "cd test; ant download_jslibs",
       },
       ThriftGen: {
         command: [
-          'mkdir -p test/gen-js',
-          '../../compiler/cpp/thrift -gen js:ts --out test/gen-js ../../test/v0.16/ThriftTest.thrift',
-          'mkdir -p test/gen-nodejs',
-          '../../compiler/cpp/thrift -gen js:node,ts --out test/gen-nodejs ../../test/v0.16/ThriftTest.thrift',
-        ].join(' && ')
+          "mkdir -p test/gen-js",
+          "../../compiler/cpp/thrift -gen js:ts --out test/gen-js ../../test/v0.16/ThriftTest.thrift",
+          "mkdir -p test/gen-nodejs",
+          "../../compiler/cpp/thrift -gen js:node,ts --out test/gen-nodejs ../../test/v0.16/ThriftTest.thrift",
+        ].join(" && "),
       },
       ThriftBrowserifyNodeInt64: {
         command: [
-          './node_modules/browserify/bin/cmd.js ./node_modules/node-int64/Int64.js -s Int64 -o test/build/js/lib/Int64.js',
-          './node_modules/browserify/bin/cmd.js ../nodejs/lib/thrift/int64_util.js -s Int64Util -o test/build/js/lib/Int64Util.js',
-          './node_modules/browserify/bin/cmd.js ./node_modules/json-int64/index.js -s JSONInt64 -o test/build/js/lib/JSONInt64.js'
-        ].join(' && ')
+          "./node_modules/browserify/bin/cmd.js ./node_modules/node-int64/Int64.js -s Int64 -o test/build/js/lib/Int64.js",
+          "./node_modules/browserify/bin/cmd.js ../nodejs/lib/thrift/int64_util.js -s Int64Util -o test/build/js/lib/Int64Util.js",
+          "./node_modules/browserify/bin/cmd.js ./node_modules/json-int64/index.js -s JSONInt64 -o test/build/js/lib/JSONInt64.js",
+        ].join(" && "),
       },
       ThriftGenInt64: {
-        command: '../../compiler/cpp/thrift -gen js:ts -o test ../../test/Int64Test.thrift'
+        command:
+          "../../compiler/cpp/thrift -gen js:ts -o test ../../test/Int64Test.thrift",
       },
       ThriftTestServer: {
         options: {
           async: true,
           execOptions: {
             cwd: "./test",
-            env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
-          }
+            env: { NODE_PATH: "../../nodejs/lib:../../../node_modules" },
+          },
         },
         command: "node server_http.js",
       },
@@ -61,103 +63,104 @@
         options: {
           execOptions: {
             cwd: "./test",
-          }
+          },
         },
-        command : "../node_modules/typescript/bin/tsc --listFiles --outDir build/ts"
+        command:
+          "../node_modules/typescript/bin/tsc --listFiles --outDir build/ts",
       },
       BrowserifyCompiledTS: {
         command: [
           "./node_modules/browserify/bin/cmd.js test/build/ts/test.js -o test/build/ts/lib/test.js --standalone test",
           "./node_modules/browserify/bin/cmd.js test/build/ts/test-int64.js -o test/build/ts/lib/test-int64.js --standalone testInt64",
-        ].join(" && ")
+        ].join(" && "),
       },
       InstallGeneratedCode: {
         command: [
           "mkdir -p test/build/ts",
-          "cp -r test/gen-js test/build/ts"
-        ].join(" && ")
+          "cp -r test/gen-js test/build/ts",
+        ].join(" && "),
       },
     },
     qunit: {
       ThriftJS: {
         options: {
-          urls: [
-            'http://localhost:8089/test.html'
-          ],
+          urls: ["http://localhost:8089/test.html"],
           puppeteer: {
             headless: true,
-            args: ['--no-sandbox'],
+            args: ["--no-sandbox"],
           },
-        }
+        },
       },
       ThriftJS_Int64: {
         options: {
-          urls: [
-            'http://localhost:8089/test-int64.html'
-          ],
+          urls: ["http://localhost:8089/test-int64.html"],
           puppeteer: {
             headless: true,
-            args: ['--no-sandbox'],
+            args: ["--no-sandbox"],
             ignoreHTTPSErrors: true,
           },
-        }
+        },
       },
     },
     jshint: {
       // The main Thrift library file. not es6 yet :(
       lib: {
-        src: ['../js/src/**/*.js'],
+        src: ["../js/src/**/*.js"],
       },
       // The test files use es6
       test: {
-        src: ['Gruntfile.js', 'test/*.js'],
+        src: ["Gruntfile.js", "test/*.js"],
         options: {
           esversion: 6,
-        }
+        },
       },
       gen_js_code: {
-        src: ['test/gen-js/*.js'],
+        src: ["test/gen-js/*.js"],
       },
       gen_node_code: {
-        src: ['test/gen-nodejs/*.js'],
+        src: ["test/gen-nodejs/*.js"],
         options: {
           node: true,
-        }
+        },
       },
     },
   });
 
-  grunt.loadNpmTasks('grunt-contrib-jshint');
-  grunt.loadNpmTasks('grunt-contrib-qunit');
-  grunt.loadNpmTasks('grunt-shell-spawn');
+  grunt.loadNpmTasks("grunt-contrib-jshint");
+  grunt.loadNpmTasks("grunt-contrib-qunit");
+  grunt.loadNpmTasks("grunt-shell-spawn");
 
-  grunt.registerTask('wait', 'Wait just one second for the server to start', function () {
-    var done = this.async();
-    setTimeout(function() {
-      done(true);
-    }, 1000);
-  });
+  grunt.registerTask(
+    "wait",
+    "Wait just one second for the server to start",
+    function () {
+      var done = this.async();
+      setTimeout(function () {
+        done(true);
+      }, 1000);
+    },
+  );
 
-  grunt.registerTask('installAndGenerate', [
-    'shell:InstallThriftJS',
-    'shell:InstallThriftNodeJSDep',
-    'shell:ThriftGen',
-    'shell:ThriftBrowserifyNodeInt64',
-    'shell:ThriftGenInt64',
-    'shell:InstallTestLibs',
-    'shell:BuildTS',
-    'shell:InstallGeneratedCode',
-    'shell:BrowserifyCompiledTS',
+  grunt.registerTask("installAndGenerate", [
+    "shell:InstallThriftJS",
+    "shell:InstallThriftNodeJSDep",
+    "shell:ThriftGen",
+    "shell:ThriftBrowserifyNodeInt64",
+    "shell:ThriftGenInt64",
+    "shell:InstallTestLibs",
+    "shell:BuildTS",
+    "shell:InstallGeneratedCode",
+    "shell:BrowserifyCompiledTS",
   ]);
 
-  grunt.registerTask('test', [
-    'installAndGenerate',
-    'jshint',
-    'shell:ThriftTestServer',
-    'wait',
-    'qunit:ThriftJS',
-    'qunit:ThriftJS_Int64',
-    'shell:ThriftTestServer:kill',
+  grunt.registerTask("test", [
+    "installAndGenerate",
+    "jshint",
+    "shell:ThriftTestServer",
+    "wait",
+    "qunit:ThriftJS",
+    "qunit:ThriftJS_Int64",
+    "shell:ThriftTestServer:kill",
   ]);
-  grunt.registerTask('default', ['test']);
+  grunt.registerTask("default", ["test"]);
 };
diff --git a/lib/ts/test/phantom-client.ts b/lib/ts/test/phantom-client.ts
index 5518937..90a532d 100644
--- a/lib/ts/test/phantom-client.ts
+++ b/lib/ts/test/phantom-client.ts
@@ -16,337 +16,360 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- /* jshint -W100 */
+/* jshint -W100 */
 
 import { ThriftTest } from "./gen-js/ThriftTest_types";
 import "./gen-js/ThriftTest";
 var Int64 = require("node-int64");
 var phantom = require("phantom");
 
-const int64_2_pow_60: typeof Int64 = new Int64('1000000000000000');
-const int64_minus_2_pow_60: typeof Int64 = new Int64('f000000000000000');
+const int64_2_pow_60: typeof Int64 = new Int64("1000000000000000");
+const int64_minus_2_pow_60: typeof Int64 = new Int64("f000000000000000");
 
- (function() {
-    'use strict';
-  
-    // Rudimentary test helper functions
-    // TODO: Return error code based on kind of errors rather than throw
-    var ok = function(t, msg) {
-      if (!t) {
-        console.log('*** FAILED ***');
-        throw new Error(msg);
+(function () {
+  "use strict";
+
+  // Rudimentary test helper functions
+  // TODO: Return error code based on kind of errors rather than throw
+  var ok = function (t, msg) {
+    if (!t) {
+      console.log("*** FAILED ***");
+      throw new Error(msg);
+    }
+  };
+  var equal = function (a, b) {
+    if (a !== b) {
+      console.log("*** FAILED ***");
+      throw new Error();
+    }
+  };
+  var test = function (name, f) {
+    console.log("TEST : " + name);
+    f();
+    console.log("OK\n");
+  };
+
+  var parseArgs = function (args) {
+    var skips = ["--transport=http", "--protocol=json"];
+    var opts = {
+      port: "9090",
+      // protocol: 'json',
+    };
+    var keys = {};
+    for (var key in opts) {
+      keys["--" + key + "="] = key;
+    }
+    for (var i in args) {
+      var arg = args[i];
+      if (skips.indexOf(arg) != -1) {
+        continue;
       }
-    };
-    var equal = function(a, b) {
-      if (a !== b) {
-        console.log('*** FAILED ***');
-        throw new Error();
+      var hit = false;
+      for (var k in keys) {
+        if (arg.slice(0, k.length) === k) {
+          opts[keys[k]] = arg.slice(k.length);
+          hit = true;
+          break;
+        }
       }
-    };
-    var test = function(name, f) {
-      console.log('TEST : ' + name);
-      f();
-      console.log('OK\n');
-    };
-  
-    var parseArgs = function(args) {
-      var skips = [
-        '--transport=http',
-        '--protocol=json'
-      ];
-      var opts = {
-        port: '9090'
-        // protocol: 'json',
+      if (!hit) {
+        throw new Error("Unknown argument: " + arg);
+      }
+    }
+    var portAsInt: number = parseInt(opts.port, 10);
+    if (!opts.port || portAsInt < 1 || portAsInt > 65535) {
+      throw new Error("Invalid port number");
+    }
+    return opts;
+  };
+
+  var execute = function () {
+    console.log("### Apache Thrift Javascript standalone test client");
+    console.log("------------------------------------------------------------");
+
+    phantom.page.injectJs("thrift.js");
+    phantom.page.injectJs("gen-js/ThriftTest_types.js");
+    phantom.page.injectJs("gen-js/ThriftTest.js");
+
+    var system = require("system");
+    var opts = parseArgs(system.args.slice(1));
+    var port = opts.port;
+    var transport = new Thrift.Transport(
+      "http://localhost:" + port + "/service",
+    );
+    var protocol = new Thrift.Protocol(transport);
+    var client = new ThriftTest.ThriftTestClient(protocol);
+
+    // TODO: Remove duplicate code with test.js.
+    // all Languages in UTF-8
+    var stringTest =
+      "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
+
+    function checkRecursively(map1, map2) {
+      if (typeof map1 !== "function" && typeof map2 !== "function") {
+        if (!map1 || typeof map1 !== "object") {
+          equal(map1, map2);
+        } else {
+          for (var key in map1) {
+            checkRecursively(map1[key], map2[key]);
+          }
+        }
+      }
+    }
+
+    test("Void", function () {
+      equal(client.testVoid(), undefined);
+    });
+    test("Binary (String)", function () {
+      var binary: string = "";
+      for (var v = 255; v >= 0; --v) {
+        binary += String.fromCharCode(v);
+      }
+      equal(client.testBinary(binary), binary);
+    });
+    test("Binary (Uint8Array)", function () {
+      var binary: string = "";
+      for (var v = 255; v >= 0; --v) {
+        binary += String.fromCharCode(v);
+      }
+      var arr = new Uint8Array(binary.length);
+      for (var i = 0; i < binary.length; ++i) {
+        arr[i] = binary[i].charCodeAt(0);
+      }
+      const hexEncodedString = Array.from(arr, function (byte) {
+        return String.fromCharCode(byte);
+      }).join("");
+      equal(client.testBinary(hexEncodedString), binary);
+    });
+    test("String", function () {
+      equal(client.testString(""), "");
+      equal(client.testString(stringTest), stringTest);
+
+      var specialCharacters =
+        'quote: \" backslash:' +
+        " forwardslash-escaped: \/ " +
+        " backspace: \b formfeed: \f newline: \n return: \r tab: " +
+        ' now-all-of-them-together: "\\\/\b\n\r\t' +
+        " now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><";
+      equal(client.testString(specialCharacters), specialCharacters);
+    });
+    test("Double", function () {
+      equal(client.testDouble(0), 0);
+      equal(client.testDouble(-1), -1);
+      equal(client.testDouble(3.14), 3.14);
+      equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
+    });
+    test("Bool", function () {
+      equal(client.testBool(true), true);
+      equal(client.testBool(false), false);
+    });
+    test("I8", function () {
+      equal(client.testByte(0), 0);
+      equal(client.testByte(0x01), 0x01);
+    });
+    test("I32", function () {
+      equal(client.testI32(0), 0);
+      equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
+      equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
+    });
+    test("I64", function () {
+      equal(client.testI64(new Int64(0)), 0);
+      equal(client.testI64(int64_2_pow_60), Math.pow(2, 52));
+      equal(client.testI64(int64_minus_2_pow_60), -Math.pow(2, 52));
+    });
+
+    test("Struct", function () {
+      var structTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
+      structTestInput.string_thing = "worked";
+      structTestInput.byte_thing = 0x01;
+      structTestInput.i32_thing = Math.pow(2, 30);
+      structTestInput.i64_thing = int64_2_pow_60;
+
+      var structTestOutput: ThriftTest.Xtruct =
+        client.testStruct(structTestInput);
+
+      equal(structTestOutput.string_thing, structTestInput.string_thing);
+      equal(structTestOutput.byte_thing, structTestInput.byte_thing);
+      equal(structTestOutput.i32_thing, structTestInput.i32_thing);
+      equal(structTestOutput.i64_thing, structTestInput.i64_thing);
+
+      equal(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
+    });
+
+    test("Nest", function () {
+      var xtrTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
+      xtrTestInput.string_thing = "worked";
+      xtrTestInput.byte_thing = 0x01;
+      xtrTestInput.i32_thing = Math.pow(2, 30);
+      xtrTestInput.i64_thing = int64_2_pow_60;
+
+      var nestTestInput: ThriftTest.Xtruct2 = new ThriftTest.Xtruct2();
+      nestTestInput.byte_thing = 0x02;
+      nestTestInput.struct_thing = xtrTestInput;
+      nestTestInput.i32_thing = Math.pow(2, 15);
+
+      var nestTestOutput = client.testNest(nestTestInput);
+
+      equal(nestTestOutput.byte_thing, nestTestInput.byte_thing);
+      equal(
+        nestTestOutput.struct_thing.string_thing,
+        nestTestInput.struct_thing.string_thing,
+      );
+      equal(
+        nestTestOutput.struct_thing.byte_thing,
+        nestTestInput.struct_thing.byte_thing,
+      );
+      equal(
+        nestTestOutput.struct_thing.i32_thing,
+        nestTestInput.struct_thing.i32_thing,
+      );
+      equal(
+        nestTestOutput.struct_thing.i64_thing,
+        nestTestInput.struct_thing.i64_thing,
+      );
+      equal(nestTestOutput.i32_thing, nestTestInput.i32_thing);
+
+      equal(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
+    });
+
+    test("Map", function () {
+      var mapTestInput: { [k: number]: number } = { 7: 77, 8: 88, 9: 99 };
+
+      var mapTestOutput: { [k: number]: number } = client.testMap(mapTestInput);
+
+      for (var key in mapTestOutput) {
+        equal(mapTestOutput[key], mapTestInput[key]);
+      }
+    });
+
+    test("StringMap", function () {
+      var mapTestInput: { [k: string]: string } = {
+        a: "123",
+        "a b": "with spaces ",
+        same: "same",
+        "0": "numeric key",
+        longValue: stringTest,
+        stringTest: "long key",
       };
-      var keys = {};
-      for (var key in opts) {
-        keys['--' + key + '='] = key;
+
+      var mapTestOutput: { [k: string]: string } =
+        client.testStringMap(mapTestInput);
+
+      for (var key in mapTestOutput) {
+        equal(mapTestOutput[key], mapTestInput[key]);
       }
-      for (var i in args) {
-        var arg = args[i];
-        if (skips.indexOf(arg) != -1) {
-          continue;
-        }
-        var hit = false;
-        for (var k in keys) {
-          if (arg.slice(0, k.length) === k) {
-            opts[keys[k]] = arg.slice(k.length);
-            hit = true;
-            break;
-          }
-        }
-        if (!hit) {
-          throw new Error('Unknown argument: ' + arg);
+    });
+
+    test("Set", function () {
+      var setTestInput: number[] = [1, 2, 3];
+      ok(client.testSet(setTestInput), setTestInput);
+    });
+
+    test("List", function () {
+      var listTestInput: number[] = [1, 2, 3];
+      ok(client.testList(listTestInput), listTestInput);
+    });
+
+    test("Enum", function () {
+      equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
+    });
+
+    test("TypeDef", function () {
+      equal(client.testTypedef(new Int64(69)), 69);
+    });
+
+    test("MapMap", function () {
+      var mapMapTestExpectedResult: { [K: number]: { [k: number]: number } } = {
+        "4": { "1": 1, "2": 2, "3": 3, "4": 4 },
+        "-4": { "-4": -4, "-3": -3, "-2": -2, "-1": -1 },
+      };
+
+      var mapMapTestOutput = client.testMapMap(1);
+
+      for (var key in mapMapTestOutput) {
+        for (var key2 in mapMapTestOutput[key]) {
+          equal(
+            mapMapTestOutput[key][key2],
+            mapMapTestExpectedResult[key][key2],
+          );
         }
       }
-      var portAsInt: number = parseInt(opts.port, 10);
-      if (!opts.port || portAsInt < 1 || portAsInt > 65535) {
-        throw new Error('Invalid port number');
+
+      checkRecursively(mapMapTestOutput, mapMapTestExpectedResult);
+    });
+
+    test("Xception", function () {
+      try {
+        client.testException("Xception");
+        ok(false, "expected an exception but there was no exception");
+      } catch (e) {
+        equal(e.errorCode, 1001);
+        equal(e.message, "Xception");
       }
-      return opts;
-    };
-  
-    var execute = function() {
-      console.log('### Apache Thrift Javascript standalone test client');
-      console.log('------------------------------------------------------------');
-  
-      phantom.page.injectJs('thrift.js');
-      phantom.page.injectJs('gen-js/ThriftTest_types.js');
-      phantom.page.injectJs('gen-js/ThriftTest.js');
-  
-      var system = require('system');
-      var opts = parseArgs(system.args.slice(1));
-      var port = opts.port;
-      var transport = new Thrift.Transport('http://localhost:' + port + '/service');
-      var protocol = new Thrift.Protocol(transport);
-      var client = new ThriftTest.ThriftTestClient(protocol);
-  
-  
-      // TODO: Remove duplicate code with test.js.
-      // all Languages in UTF-8
-      var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
-  
-      function checkRecursively(map1, map2) {
-        if (typeof map1 !== 'function' && typeof map2 !== 'function') {
-          if (!map1 || typeof map1 !== 'object') {
-            equal(map1, map2);
-          } else {
-            for (var key in map1) {
-              checkRecursively(map1[key], map2[key]);
-            }
-          }
-        }
+    });
+
+    test("no Exception", function () {
+      try {
+        client.testException("no Exception");
+      } catch (e) {
+        ok(false, "expected no exception but here was an exception");
       }
-  
-      test('Void', function() {
-        equal(client.testVoid(), undefined);
-      });
-      test('Binary (String)', function() {
-        var binary: string = '';
-        for (var v = 255; v >= 0; --v) {
-          binary += String.fromCharCode(v);
-        }
-        equal(client.testBinary(binary), binary);
-      });
-      test('Binary (Uint8Array)', function() {
-        var binary: string = '';
-        for (var v = 255; v >= 0; --v) {
-          binary += String.fromCharCode(v);
-        }
-        var arr = new Uint8Array(binary.length);
-        for (var i = 0; i < binary.length; ++i) {
-          arr[i] = binary[i].charCodeAt(0);
-        }
-        const hexEncodedString = Array.from(arr, function(byte) {
-            return String.fromCharCode(byte);
-        }).join('')
-        equal(client.testBinary(hexEncodedString), binary);
-      });
-      test('String', function() {
-        equal(client.testString(''), '');
-        equal(client.testString(stringTest), stringTest);
-  
-        var specialCharacters = 'quote: \" backslash:' +
-          ' forwardslash-escaped: \/ ' +
-            ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
-              ' now-all-of-them-together: "\\\/\b\n\r\t' +
-                ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
-                equal(client.testString(specialCharacters), specialCharacters);
-      });
-      test('Double', function() {
-        equal(client.testDouble(0), 0);
-        equal(client.testDouble(-1), -1);
-        equal(client.testDouble(3.14), 3.14);
-        equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
-      });
-      test('Bool', function() {
-        equal(client.testBool(true), true);
-        equal(client.testBool(false), false);
-      });
-      test('I8', function() {
-        equal(client.testByte(0), 0);
-        equal(client.testByte(0x01), 0x01);
-      });
-      test('I32', function() {
-        equal(client.testI32(0), 0);
-        equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
-        equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
-      });
-      test('I64', function() {
-        equal(client.testI64(new Int64(0)), 0);
-        equal(client.testI64(int64_2_pow_60), Math.pow(2, 52));
-        equal(client.testI64(int64_minus_2_pow_60), -Math.pow(2, 52));
-      });
-  
-      test('Struct', function() {
-        var structTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
-        structTestInput.string_thing = 'worked';
-        structTestInput.byte_thing = 0x01;
-        structTestInput.i32_thing = Math.pow(2, 30);
-        structTestInput.i64_thing = int64_2_pow_60;
-  
-        var structTestOutput: ThriftTest.Xtruct = client.testStruct(structTestInput);
-  
-        equal(structTestOutput.string_thing, structTestInput.string_thing);
-        equal(structTestOutput.byte_thing, structTestInput.byte_thing);
-        equal(structTestOutput.i32_thing, structTestInput.i32_thing);
-        equal(structTestOutput.i64_thing, structTestInput.i64_thing);
-  
-        equal(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
-      });
-  
-      test('Nest', function() {
-        var xtrTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
-        xtrTestInput.string_thing = 'worked';
-        xtrTestInput.byte_thing = 0x01;
-        xtrTestInput.i32_thing = Math.pow(2, 30);
-        xtrTestInput.i64_thing = int64_2_pow_60;
-  
-        var nestTestInput: ThriftTest.Xtruct2 = new ThriftTest.Xtruct2();
-        nestTestInput.byte_thing = 0x02;
-        nestTestInput.struct_thing = xtrTestInput;
-        nestTestInput.i32_thing = Math.pow(2, 15);
-  
-        var nestTestOutput = client.testNest(nestTestInput);
-  
-        equal(nestTestOutput.byte_thing, nestTestInput.byte_thing);
-        equal(nestTestOutput.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
-        equal(nestTestOutput.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
-        equal(nestTestOutput.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
-        equal(nestTestOutput.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
-        equal(nestTestOutput.i32_thing, nestTestInput.i32_thing);
-  
-        equal(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
-      });
-  
-      test('Map', function() {
-        var mapTestInput: {[k: number]: number;} = {7: 77, 8: 88, 9: 99};
-  
-        var mapTestOutput: {[k: number]: number;} = client.testMap(mapTestInput);
-  
-        for (var key in mapTestOutput) {
-          equal(mapTestOutput[key], mapTestInput[key]);
-        }
-      });
-  
-      test('StringMap', function() {
-        var mapTestInput: {[k: string]: string;} = {
-          'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
-          'longValue': stringTest, stringTest: 'long key'
-        };
-  
-        var mapTestOutput: {[k: string]: string;} = client.testStringMap(mapTestInput);
-  
-        for (var key in mapTestOutput) {
-          equal(mapTestOutput[key], mapTestInput[key]);
-        }
-      });
-  
-      test('Set', function() {
-        var setTestInput: number[] = [1, 2, 3];
-        ok(client.testSet(setTestInput), setTestInput);
-      });
-  
-      test('List', function() {
-        var listTestInput: number[] = [1, 2, 3];
-        ok(client.testList(listTestInput), listTestInput);
-      });
-  
-      test('Enum', function() {
-        equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
-      });
-  
-      test('TypeDef', function() {
-        equal(client.testTypedef(new Int64(69)), 69);
-      });
-  
-      test('MapMap', function() {
-        var mapMapTestExpectedResult: {[K: number]: {[k: number]: number}} = {
-          '4': {'1': 1, '2': 2, '3': 3, '4': 4},
-          '-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
-        };
-  
-        var mapMapTestOutput = client.testMapMap(1);
-  
-  
-        for (var key in mapMapTestOutput) {
-          for (var key2 in mapMapTestOutput[key]) {
-            equal(mapMapTestOutput[key][key2], mapMapTestExpectedResult[key][key2]);
-          }
-        }
-  
-        checkRecursively(mapMapTestOutput, mapMapTestExpectedResult);
-      });
-  
-      test('Xception', function() {
-        try {
-          client.testException('Xception');
-          ok(false, "expected an exception but there was no exception");
-        } catch (e) {
-          equal(e.errorCode, 1001);
-          equal(e.message, 'Xception');
-        }
-      });
-  
-      test('no Exception', function() {
-        try {
-          client.testException('no Exception');
-        } catch (e) {
-          ok(false, "expected no exception but here was an exception");
-        }
-      });
-  
-      test('TException', function() {
-        try {
-          client.testException('TException');
-          ok(false, "expected an exception but there was no exception");
-        } catch (e) {
-          ok(ok, "succesfully got exception");
-        }
-      });
-  
-      const crazy: ThriftTest.Insanity = {
-        'userMap': { '5': new Int64(5), '8': new Int64(8) },
-        'xtructs': [{
-            'string_thing': 'Goodbye4',
-            'byte_thing': 4,
-            'i32_thing': 4,
-            'i64_thing': new Int64(4)
+    });
+
+    test("TException", function () {
+      try {
+        client.testException("TException");
+        ok(false, "expected an exception but there was no exception");
+      } catch (e) {
+        ok(ok, "succesfully got exception");
+      }
+    });
+
+    const crazy: ThriftTest.Insanity = {
+      userMap: { "5": new Int64(5), "8": new Int64(8) },
+      xtructs: [
+        {
+          string_thing: "Goodbye4",
+          byte_thing: 4,
+          i32_thing: 4,
+          i64_thing: new Int64(4),
         },
         {
-            'string_thing': 'Hello2',
-            'byte_thing': 2,
-            'i32_thing': 2,
-            'i64_thing': new Int64(2)
-        }]
+          string_thing: "Hello2",
+          byte_thing: 2,
+          i32_thing: 2,
+          i64_thing: new Int64(2),
+        },
+      ],
     };
-      test('Insanity', function() {
-        const insanity: {[k: number]: (ThriftTest.Insanity | {[k:number]: ThriftTest.Insanity})} = {
-            '1': {
-                '2': crazy,
-                '3': crazy
-            },
-            '2': { '6': new ThriftTest.Insanity() }
-        };
-        var res = client.testInsanity(new ThriftTest.Insanity(crazy));
-        ok(res, JSON.stringify(res));
-        ok(insanity, JSON.stringify(insanity));
-  
-        checkRecursively(res, insanity);
-      });
-  
-      console.log('------------------------------------------------------------');
-      console.log('### All tests succeeded.');
-      return 0;
-    };
-  
-    try {
-      var ret = execute();
-      phantom.exit(ret);
-    } catch (err) {
-      // Catch all and exit to avoid hang.
-      console.error(err);
-      phantom.exit(1);
-    }
-  })();
-  
\ No newline at end of file
+    test("Insanity", function () {
+      const insanity: {
+        [k: number]: ThriftTest.Insanity | { [k: number]: ThriftTest.Insanity };
+      } = {
+        "1": {
+          "2": crazy,
+          "3": crazy,
+        },
+        "2": { "6": new ThriftTest.Insanity() },
+      };
+      var res = client.testInsanity(new ThriftTest.Insanity(crazy));
+      ok(res, JSON.stringify(res));
+      ok(insanity, JSON.stringify(insanity));
+
+      checkRecursively(res, insanity);
+    });
+
+    console.log("------------------------------------------------------------");
+    console.log("### All tests succeeded.");
+    return 0;
+  };
+
+  try {
+    var ret = execute();
+    phantom.exit(ret);
+  } catch (err) {
+    // Catch all and exit to avoid hang.
+    console.error(err);
+    phantom.exit(1);
+  }
+})();
diff --git a/lib/ts/test/server_http.js b/lib/ts/test/server_http.js
index 8380c3a..662a0a7 100644
--- a/lib/ts/test/server_http.js
+++ b/lib/ts/test/server_http.js
@@ -28,28 +28,30 @@
 //  for the es6 environment or for pre-es6 environment.
 //
 
-const thrift = require('../../nodejs/lib/thrift');
-const es6Mode = process.argv.includes('--es6');
-const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
+const thrift = require("../../nodejs/lib/thrift");
+const es6Mode = process.argv.includes("--es6");
+const genFolder = es6Mode ? "gen-nodejs-es6" : "gen-nodejs";
 const ThriftTestSvc = require(`./${genFolder}/ThriftTest.js`);
-const ThriftTestHandler = require('./test_handler').ThriftTestHandler;
+const ThriftTestHandler = require("./test_handler").ThriftTestHandler;
 
 const ThriftTestSvcOpt = {
-	transport: thrift.TBufferedTransport,
-	protocol: thrift.TJSONProtocol,
-	processor: ThriftTestSvc,
-	handler: ThriftTestHandler
+  transport: thrift.TBufferedTransport,
+  protocol: thrift.TJSONProtocol,
+  processor: ThriftTestSvc,
+  handler: ThriftTestHandler,
 };
 
 const ThriftWebServerOptions = {
-	files: __dirname,
-	services: {
-		'/service': ThriftTestSvcOpt
-	}
+  files: __dirname,
+  services: {
+    "/service": ThriftTestSvcOpt,
+  },
 };
 
 const server = thrift.createWebServer(ThriftWebServerOptions);
 const port = es6Mode ? 8088 : 8089;
 server.listen(port);
 console.log(`Serving files from: ${__dirname}`);
-console.log(`Http/Thrift Server (ES6 mode ${es6Mode}) running on port: ${port}`);
+console.log(
+  `Http/Thrift Server (ES6 mode ${es6Mode}) running on port: ${port}`,
+);
diff --git a/lib/ts/test/test-int64.ts b/lib/ts/test/test-int64.ts
index 254d8d7..10e5946 100644
--- a/lib/ts/test/test-int64.ts
+++ b/lib/ts/test/test-int64.ts
@@ -16,86 +16,90 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- /* jshint -W100 */
+/* jshint -W100 */
 
 var Int64 = require("node-int64");
 var JSONInt64 = require("json-int64");
 import { Int64Test } from "./gen-js/Int64Test_types";
 
-
 // Work around for old API used by QUnitAdapter of jsTestDriver
-if (typeof QUnit.log == 'function') {
+if (typeof QUnit.log == "function") {
   // When using real QUnit (fron PhantomJS) log failures to console
-  QUnit.log(function(details) {
+  QUnit.log(function (details) {
     if (!details.result) {
-      console.log('======== FAIL ========');
-      console.log('TestName: ' + details.name);
+      console.log("======== FAIL ========");
+      console.log("TestName: " + details.name);
       if (details.message) console.log(details.message);
-      console.log('Expected: ' + details.expected);
-      console.log('Actual  : ' + details.actual);
-      console.log('======================');
+      console.log("Expected: " + details.expected);
+      console.log("Actual  : " + details.actual);
+      console.log("======================");
     }
   });
 }
 
-QUnit.module('Int64');
+QUnit.module("Int64");
 
-  QUnit.test('Int64', function(assert) {
-    console.log('Int64 test -- starts');
-    const EXPECTED_SMALL_INT64_AS_NUMBER: number = 42;
-    const EXPECTED_SMALL_INT64: typeof Int64 = new Int64(42);
-    const EXPECTED_MAX_JS_SAFE_INT64: typeof Int64 = new Int64(Number.MAX_SAFE_INTEGER);
-    const EXPECTED_MIN_JS_SAFE_INT64: typeof Int64 = new Int64(Number.MIN_SAFE_INTEGER);
-    const EXPECTED_MAX_JS_SAFE_PLUS_ONE_INT64: typeof Int64 = new Int64("0020000000000000"); // hex-encoded
-    const EXPECTED_MIN_JS_SAFE_MINUS_ONE_INT64: typeof Int64 = new Int64("ffe0000000000000"); // hex-encoded 2's complement
-    const EXPECTED_MAX_SIGNED_INT64: typeof Int64 = new Int64("7fffffffffffffff"); // hex-encoded
-    const EXPECTED_MIN_SIGNED_INT64: typeof Int64 = new Int64("8000000000000000"); // hex-encoded 2's complement
-    const EXPECTED_INT64_LIST = [
-      EXPECTED_SMALL_INT64,
-      EXPECTED_MAX_JS_SAFE_INT64,
-      EXPECTED_MIN_JS_SAFE_INT64,
-      EXPECTED_MAX_JS_SAFE_PLUS_ONE_INT64,
-      EXPECTED_MIN_JS_SAFE_MINUS_ONE_INT64,
-      EXPECTED_MAX_SIGNED_INT64,
-      EXPECTED_MIN_SIGNED_INT64
-    ];
-    assert.ok(EXPECTED_SMALL_INT64.equals(Int64Test.SMALL_INT64));
-    assert.ok(EXPECTED_MAX_JS_SAFE_INT64.equals(Int64Test.MAX_JS_SAFE_INT64));
-    assert.ok(EXPECTED_MIN_JS_SAFE_INT64.equals(Int64Test.MIN_JS_SAFE_INT64));
+QUnit.test("Int64", function (assert) {
+  console.log("Int64 test -- starts");
+  const EXPECTED_SMALL_INT64_AS_NUMBER: number = 42;
+  const EXPECTED_SMALL_INT64: typeof Int64 = new Int64(42);
+  const EXPECTED_MAX_JS_SAFE_INT64: typeof Int64 = new Int64(
+    Number.MAX_SAFE_INTEGER,
+  );
+  const EXPECTED_MIN_JS_SAFE_INT64: typeof Int64 = new Int64(
+    Number.MIN_SAFE_INTEGER,
+  );
+  const EXPECTED_MAX_JS_SAFE_PLUS_ONE_INT64: typeof Int64 = new Int64(
+    "0020000000000000",
+  ); // hex-encoded
+  const EXPECTED_MIN_JS_SAFE_MINUS_ONE_INT64: typeof Int64 = new Int64(
+    "ffe0000000000000",
+  ); // hex-encoded 2's complement
+  const EXPECTED_MAX_SIGNED_INT64: typeof Int64 = new Int64("7fffffffffffffff"); // hex-encoded
+  const EXPECTED_MIN_SIGNED_INT64: typeof Int64 = new Int64("8000000000000000"); // hex-encoded 2's complement
+  const EXPECTED_INT64_LIST = [
+    EXPECTED_SMALL_INT64,
+    EXPECTED_MAX_JS_SAFE_INT64,
+    EXPECTED_MIN_JS_SAFE_INT64,
+    EXPECTED_MAX_JS_SAFE_PLUS_ONE_INT64,
+    EXPECTED_MIN_JS_SAFE_MINUS_ONE_INT64,
+    EXPECTED_MAX_SIGNED_INT64,
+    EXPECTED_MIN_SIGNED_INT64,
+  ];
+  assert.ok(EXPECTED_SMALL_INT64.equals(Int64Test.SMALL_INT64));
+  assert.ok(EXPECTED_MAX_JS_SAFE_INT64.equals(Int64Test.MAX_JS_SAFE_INT64));
+  assert.ok(EXPECTED_MIN_JS_SAFE_INT64.equals(Int64Test.MIN_JS_SAFE_INT64));
+  assert.ok(
+    EXPECTED_MAX_JS_SAFE_PLUS_ONE_INT64.equals(
+      Int64Test.MAX_JS_SAFE_PLUS_ONE_INT64,
+    ),
+  );
+  assert.ok(
+    EXPECTED_MIN_JS_SAFE_MINUS_ONE_INT64.equals(
+      Int64Test.MIN_JS_SAFE_MINUS_ONE_INT64,
+    ),
+  );
+  assert.ok(EXPECTED_MAX_SIGNED_INT64.equals(Int64Test.MAX_SIGNED_INT64));
+  assert.ok(EXPECTED_MIN_SIGNED_INT64.equals(Int64Test.MIN_SIGNED_INT64));
+  assert.equal(
+    EXPECTED_SMALL_INT64_AS_NUMBER,
+    Int64Test.SMALL_INT64.toNumber(),
+  );
+  assert.equal(Number.MAX_SAFE_INTEGER, Int64Test.MAX_JS_SAFE_INT64.toNumber());
+  assert.equal(Number.MIN_SAFE_INTEGER, Int64Test.MIN_JS_SAFE_INT64.toNumber());
+
+  for (let i = 0; i < EXPECTED_INT64_LIST.length; ++i) {
+    assert.ok(EXPECTED_INT64_LIST[i].equals(Int64Test.INT64_LIST[i]));
+  }
+
+  for (let i = 0; i < EXPECTED_INT64_LIST.length; ++i) {
+    let int64Object = EXPECTED_INT64_LIST[i];
     assert.ok(
-      EXPECTED_MAX_JS_SAFE_PLUS_ONE_INT64.equals(
-        Int64Test.MAX_JS_SAFE_PLUS_ONE_INT64
-      )
+      Int64Test.INT64_2_INT64_MAP[
+        JSONInt64.toDecimalString(int64Object)
+      ].equals(int64Object),
     );
-    assert.ok(
-      EXPECTED_MIN_JS_SAFE_MINUS_ONE_INT64.equals(
-        Int64Test.MIN_JS_SAFE_MINUS_ONE_INT64
-      )
-    );
-    assert.ok(EXPECTED_MAX_SIGNED_INT64.equals(Int64Test.MAX_SIGNED_INT64));
-    assert.ok(EXPECTED_MIN_SIGNED_INT64.equals(Int64Test.MIN_SIGNED_INT64));
-    assert.equal(
-      EXPECTED_SMALL_INT64_AS_NUMBER,
-      Int64Test.SMALL_INT64.toNumber()
-    );
-    assert.equal(
-      Number.MAX_SAFE_INTEGER,
-      Int64Test.MAX_JS_SAFE_INT64.toNumber()
-    );
-    assert.equal(
-      Number.MIN_SAFE_INTEGER,
-      Int64Test.MIN_JS_SAFE_INT64.toNumber()
-    );
+  }
 
-    for (let i = 0; i < EXPECTED_INT64_LIST.length; ++i) {
-      assert.ok(EXPECTED_INT64_LIST[i].equals(Int64Test.INT64_LIST[i]));
-    }
-
-    for (let i = 0; i < EXPECTED_INT64_LIST.length; ++i){
-      let int64Object = EXPECTED_INT64_LIST[i];
-      assert.ok(Int64Test.INT64_2_INT64_MAP[JSONInt64.toDecimalString(int64Object)].equals(int64Object));
-    }
-
-    console.log('Int64 test -- ends');
-  });
-
+  console.log("Int64 test -- ends");
+});
diff --git a/lib/ts/test/test.ts b/lib/ts/test/test.ts
index 31fdcbf..614461d 100644
--- a/lib/ts/test/test.ts
+++ b/lib/ts/test/test.ts
@@ -7,336 +7,365 @@
 
 const transport: Thrift.Transport = new Thrift.Transport("/service");
 const protocol: Thrift.Protocol = new Thrift.Protocol(transport);
-const client: ThriftTest.ThriftTestClient = new ThriftTest.ThriftTestClient(protocol);
+const client: ThriftTest.ThriftTestClient = new ThriftTest.ThriftTestClient(
+  protocol,
+);
 
-const int64_2_pow_60: typeof Int64 = new Int64('1000000000000000');
-const int64_minus_2_pow_60: typeof Int64 = new Int64('f000000000000000');
+const int64_2_pow_60: typeof Int64 = new Int64("1000000000000000");
+const int64_minus_2_pow_60: typeof Int64 = new Int64("f000000000000000");
 
 // Work around for old API used by QUnitAdapter of jsTestDriver
-if (typeof QUnit.log == 'function') {
-    // When using real QUnit (fron PhantomJS) log failures to console
-    QUnit.log(function(details) {
-        if (!details.result) {
-        console.log('======== FAIL ========');
-        console.log('TestName: ' + details.name);
-        if (details.message) console.log(details.message);
-        console.log('Expected: ' + JSONInt64.stringify(details.expected));
-        console.log('Actual  : ' + JSONInt64.stringify(details.actual));
-        console.log('======================');
-        }
-    });
+if (typeof QUnit.log == "function") {
+  // When using real QUnit (fron PhantomJS) log failures to console
+  QUnit.log(function (details) {
+    if (!details.result) {
+      console.log("======== FAIL ========");
+      console.log("TestName: " + details.name);
+      if (details.message) console.log(details.message);
+      console.log("Expected: " + JSONInt64.stringify(details.expected));
+      console.log("Actual  : " + JSONInt64.stringify(details.actual));
+      console.log("======================");
+    }
+  });
 }
 
 // all Languages in UTF-8
-const stringTest: string = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
-
+const stringTest: string =
+  "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語";
 
 function checkRecursively(assert, map1: Object, map2: Object): void {
-    if (typeof map1 !== 'function' && typeof map2 !== 'function') {
-        if (!map1 || typeof map1 !== 'object') {
-            assert.equal(map1, map2);
-        } else {
-            for (let key in map1) {
-            checkRecursively(assert, map1[key], map2[key]);
-            }
-        }
+  if (typeof map1 !== "function" && typeof map2 !== "function") {
+    if (!map1 || typeof map1 !== "object") {
+      assert.equal(map1, map2);
+    } else {
+      for (let key in map1) {
+        checkRecursively(assert, map1[key], map2[key]);
+      }
     }
+  }
 }
 
+QUnit.module("Base Types");
 
-QUnit.module('Base Types');
+QUnit.test("Void", function (assert) {
+  assert.equal(client.testVoid(), undefined);
+});
+QUnit.test("Binary (String)", function (assert) {
+  let binary: string = "";
+  for (let v = 255; v >= 0; --v) {
+    binary += String.fromCharCode(v);
+  }
+  assert.equal(client.testBinary(binary), binary);
+});
+QUnit.test("Binary (Uint8Array)", function (assert) {
+  let binary: string = "";
+  for (let v = 255; v >= 0; --v) {
+    binary += String.fromCharCode(v);
+  }
+  const arr: Uint8Array = new Uint8Array(binary.length);
+  for (let i = 0; i < binary.length; ++i) {
+    arr[i] = binary[i].charCodeAt(0);
+  }
+  const hexEncodedString = Array.from(arr, function (byte) {
+    return String.fromCharCode(byte);
+  }).join("");
+  assert.equal(client.testBinary(hexEncodedString), binary);
+});
+QUnit.test("String", function (assert) {
+  assert.equal(client.testString(""), "");
+  assert.equal(client.testString(stringTest), stringTest);
 
-    QUnit.test('Void', function(assert) {
-        assert.equal(client.testVoid(), undefined);
-    });
-    QUnit.test('Binary (String)', function(assert) {
-        let binary: string = '';
-        for (let v = 255; v >= 0; --v) {
-            binary += String.fromCharCode(v);
-        }
-        assert.equal(client.testBinary(binary), binary);
-    });
-    QUnit.test('Binary (Uint8Array)', function(assert) {
-        let binary: string = '';
-        for (let v = 255; v >= 0; --v) {
-            binary += String.fromCharCode(v);
-        }
-        const arr: Uint8Array = new Uint8Array(binary.length);
-        for (let i = 0; i < binary.length; ++i) {
-            arr[i] = binary[i].charCodeAt(0);
-        }
-        const hexEncodedString = Array.from(arr, function(byte) {
-            return String.fromCharCode(byte);
-        }).join('')
-        assert.equal(client.testBinary(hexEncodedString), binary);
-    });
-    QUnit.test('String', function(assert) {
-        assert.equal(client.testString(''), '');
-        assert.equal(client.testString(stringTest), stringTest);
+  const specialCharacters: string =
+    'quote: \" backslash:' +
+    " forwardslash-escaped: \/ " +
+    " backspace: \b formfeed: \f newline: \n return: \r tab: " +
+    ' now-all-of-them-together: "\\\/\b\n\r\t' +
+    " now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><";
+  assert.equal(client.testString(specialCharacters), specialCharacters);
+});
+QUnit.test("Double", function (assert) {
+  assert.equal(client.testDouble(0), 0);
+  assert.equal(client.testDouble(-1), -1);
+  assert.equal(client.testDouble(3.14), 3.14);
+  assert.equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
+});
+QUnit.test("Byte", function (assert) {
+  assert.equal(client.testByte(0), 0);
+  assert.equal(client.testByte(0x01), 0x01);
+});
+QUnit.test("I32", function (assert) {
+  assert.equal(client.testI32(0), 0);
+  assert.equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
+  assert.equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
+});
+QUnit.test("I64", function (assert) {
+  assert.equal(client.testI64(new Int64(0)), 0);
 
-        const specialCharacters: string = 'quote: \" backslash:' +
-            ' forwardslash-escaped: \/ ' +
-            ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
-            ' now-all-of-them-together: "\\\/\b\n\r\t' +
-            ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><';
-        assert.equal(client.testString(specialCharacters), specialCharacters);
-    });
-    QUnit.test('Double', function(assert) {
-        assert.equal(client.testDouble(0), 0);
-        assert.equal(client.testDouble(-1), -1);
-        assert.equal(client.testDouble(3.14), 3.14);
-        assert.equal(client.testDouble(Math.pow(2, 60)), Math.pow(2, 60));
-    });
-    QUnit.test('Byte', function(assert) {
-        assert.equal(client.testByte(0), 0);
-        assert.equal(client.testByte(0x01), 0x01);
-    });
-    QUnit.test('I32', function(assert) {
-        assert.equal(client.testI32(0), 0);
-        assert.equal(client.testI32(Math.pow(2, 30)), Math.pow(2, 30));
-        assert.equal(client.testI32(-Math.pow(2, 30)), -Math.pow(2, 30));
-    });
-    QUnit.test('I64', function(assert) {
-        assert.equal(client.testI64(new Int64(0)), 0);
+  let int64_2_pow_60_result: typeof Int64 = client.testI64(int64_2_pow_60);
+  assert.ok(int64_2_pow_60.equals(int64_2_pow_60_result));
 
-        let int64_2_pow_60_result: typeof Int64 = client.testI64(int64_2_pow_60);
-        assert.ok(int64_2_pow_60.equals(int64_2_pow_60_result));
+  let int64_minus_2_pow_60_result: typeof Int64 =
+    client.testI64(int64_minus_2_pow_60);
+  assert.ok(int64_minus_2_pow_60.equals(int64_minus_2_pow_60_result));
+});
 
-        let int64_minus_2_pow_60_result: typeof Int64 = client.testI64(int64_minus_2_pow_60);
-        assert.ok(int64_minus_2_pow_60.equals(int64_minus_2_pow_60_result));
-    });
+QUnit.module("Structured Types");
 
+QUnit.test("Struct", function (assert) {
+  const structTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
+  structTestInput.string_thing = "worked";
+  structTestInput.byte_thing = 0x01;
+  structTestInput.i32_thing = Math.pow(2, 30);
+  structTestInput.i64_thing = int64_2_pow_60;
 
-QUnit.module('Structured Types');
+  const structTestOutput: ThriftTest.Xtruct =
+    client.testStruct(structTestInput);
 
-    QUnit.test('Struct', function(assert) {
-        const structTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
-        structTestInput.string_thing = 'worked';
-        structTestInput.byte_thing = 0x01;
-        structTestInput.i32_thing = Math.pow(2, 30);
-        structTestInput.i64_thing = int64_2_pow_60;
+  assert.equal(structTestOutput.string_thing, structTestInput.string_thing);
+  assert.equal(structTestOutput.byte_thing, structTestInput.byte_thing);
+  assert.equal(structTestOutput.i32_thing, structTestInput.i32_thing);
+  assert.ok(structTestOutput.i64_thing.equals(structTestInput.i64_thing));
+  assert.ok(structTestInput.i64_thing.equals(structTestOutput.i64_thing));
 
-        const structTestOutput: ThriftTest.Xtruct = client.testStruct(structTestInput);
+  assert.equal(
+    JSONInt64.stringify(structTestOutput),
+    JSONInt64.stringify(structTestInput),
+  );
+});
 
-        assert.equal(structTestOutput.string_thing, structTestInput.string_thing);
-        assert.equal(structTestOutput.byte_thing, structTestInput.byte_thing);
-        assert.equal(structTestOutput.i32_thing, structTestInput.i32_thing);
-        assert.ok(structTestOutput.i64_thing.equals(structTestInput.i64_thing));
-        assert.ok(structTestInput.i64_thing.equals(structTestOutput.i64_thing));
+QUnit.test("Nest", function (assert) {
+  const xtrTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
+  xtrTestInput.string_thing = "worked";
+  xtrTestInput.byte_thing = 0x01;
+  xtrTestInput.i32_thing = Math.pow(2, 30);
+  xtrTestInput.i64_thing = int64_2_pow_60;
 
-        assert.equal(JSONInt64.stringify(structTestOutput), JSONInt64.stringify(structTestInput));
-    });
+  const nestTestInput: ThriftTest.Xtruct2 = new ThriftTest.Xtruct2();
+  nestTestInput.byte_thing = 0x02;
+  nestTestInput.struct_thing = xtrTestInput;
+  nestTestInput.i32_thing = Math.pow(2, 15);
 
-    QUnit.test('Nest', function(assert) {
-        const xtrTestInput: ThriftTest.Xtruct = new ThriftTest.Xtruct();
-        xtrTestInput.string_thing = 'worked';
-        xtrTestInput.byte_thing = 0x01;
-        xtrTestInput.i32_thing = Math.pow(2, 30);
-        xtrTestInput.i64_thing = int64_2_pow_60;
+  const nestTestOutput: ThriftTest.Xtruct2 = client.testNest(nestTestInput);
 
-        const nestTestInput: ThriftTest.Xtruct2 = new ThriftTest.Xtruct2();
-        nestTestInput.byte_thing = 0x02;
-        nestTestInput.struct_thing = xtrTestInput;
-        nestTestInput.i32_thing = Math.pow(2, 15);
+  assert.equal(nestTestOutput.byte_thing, nestTestInput.byte_thing);
+  assert.equal(
+    nestTestOutput.struct_thing.string_thing,
+    nestTestInput.struct_thing.string_thing,
+  );
+  assert.equal(
+    nestTestOutput.struct_thing.byte_thing,
+    nestTestInput.struct_thing.byte_thing,
+  );
+  assert.equal(
+    nestTestOutput.struct_thing.i32_thing,
+    nestTestInput.struct_thing.i32_thing,
+  );
+  assert.ok(
+    nestTestOutput.struct_thing.i64_thing.equals(
+      nestTestInput.struct_thing.i64_thing,
+    ),
+  );
+  assert.equal(nestTestOutput.i32_thing, nestTestInput.i32_thing);
 
-        const nestTestOutput: ThriftTest.Xtruct2 = client.testNest(nestTestInput);
+  assert.equal(
+    JSONInt64.stringify(nestTestOutput),
+    JSONInt64.stringify(nestTestInput),
+  );
+});
 
-        assert.equal(nestTestOutput.byte_thing, nestTestInput.byte_thing);
-        assert.equal(nestTestOutput.struct_thing.string_thing, nestTestInput.struct_thing.string_thing);
-        assert.equal(nestTestOutput.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing);
-        assert.equal(nestTestOutput.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing);
-        assert.ok(nestTestOutput.struct_thing.i64_thing.equals(nestTestInput.struct_thing.i64_thing));
-        assert.equal(nestTestOutput.i32_thing, nestTestInput.i32_thing);
+QUnit.test("Map", function (assert) {
+  const mapTestInput: { [k: number]: number } = { 7: 77, 8: 88, 9: 99 };
 
-        assert.equal(JSONInt64.stringify(nestTestOutput), JSONInt64.stringify(nestTestInput));
-    });
-    
-    QUnit.test('Map', function(assert) {
-        const mapTestInput: {[k: number]: number;} = {7: 77, 8: 88, 9: 99};
-    
-        const mapTestOutput: {[k: number]: number;} = client.testMap(mapTestInput);
-    
-        for (let key in mapTestOutput) {
-            assert.equal(mapTestOutput[key], mapTestInput[key]);
-        }
-    });
-    
-    QUnit.test('StringMap', function(assert) {
-        const mapTestInput: {[k: string]: string;} = {
-            'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key',
-            'longValue': stringTest, stringTest: 'long key'
-        };
-    
-        const mapTestOutput: {[k: string]: string;} = client.testStringMap(mapTestInput);
-    
-        for (let key in mapTestOutput) {
-            assert.equal(mapTestOutput[key], mapTestInput[key]);
-        }
-    });
-    
-    QUnit.test('Set', function(assert) {
-        const setTestInput: number[] = [1, 2, 3];
-        assert.ok(client.testSet(setTestInput), setTestInput);
-    });
-    
-    QUnit.test('List', function(assert) {
-        const listTestInput: number[] = [1, 2, 3];
-        assert.ok(client.testList(listTestInput), listTestInput);
-    });
-    
-    QUnit.test('Enum', function(assert) {
-        assert.equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
-    });
-    
-    QUnit.test('TypeDef', function(assert) {
-        assert.equal(client.testTypedef(new Int64(69)), 69);
-    });
+  const mapTestOutput: { [k: number]: number } = client.testMap(mapTestInput);
 
+  for (let key in mapTestOutput) {
+    assert.equal(mapTestOutput[key], mapTestInput[key]);
+  }
+});
 
-QUnit.module('deeper!');
+QUnit.test("StringMap", function (assert) {
+  const mapTestInput: { [k: string]: string } = {
+    a: "123",
+    "a b": "with spaces ",
+    same: "same",
+    "0": "numeric key",
+    longValue: stringTest,
+    stringTest: "long key",
+  };
 
-    QUnit.test('MapMap', function(assert) {
-        const mapMapTestExpectedResult: {[K: number]: {[k: number]: number}} = {
-            '4': {'1': 1, '2': 2, '3': 3, '4': 4},
-            '-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1}
-        };
-    
-        const mapMapTestOutput = client.testMapMap(1);
-    
-    
-        for (let key in mapMapTestOutput) {
-            for (let key2 in mapMapTestOutput[key]) {
-                assert.equal(mapMapTestOutput[key][key2], mapMapTestExpectedResult[key][key2]);
-            }
-        }
-    
-        checkRecursively(assert, mapMapTestOutput, mapMapTestExpectedResult);
-    });
+  const mapTestOutput: { [k: string]: string } =
+    client.testStringMap(mapTestInput);
 
+  for (let key in mapTestOutput) {
+    assert.equal(mapTestOutput[key], mapTestInput[key]);
+  }
+});
 
-QUnit.module('Exception');
+QUnit.test("Set", function (assert) {
+  const setTestInput: number[] = [1, 2, 3];
+  assert.ok(client.testSet(setTestInput), setTestInput);
+});
 
-    QUnit.test('Xception', function(assert) {
-        assert.expect(2);
-        const done = assert.async();
-        try {
-            client.testException('Xception');
-            assert.ok(false);
-        }catch (e) {
-            assert.equal(e.errorCode, 1001);
-            assert.equal(e.message, 'Xception');
-            done();
-        }
-    });
-  
-    QUnit.test('no Exception', function(assert) {
-        assert.expect(1);
-        try {
-            client.testException('no Exception');
-            assert.ok(true);
-        }catch (e) {
-            assert.ok(false);
-        }
-    });
-  
-    QUnit.test('TException', function(assert) {
-        //ThriftTest does not list TException as a legal exception so it will
-        // generate an exception on the server that does not propagate back to
-        // the client. This test has been modified to equate to "no exception"
-        assert.expect(1);
-        try {
-            client.testException('TException');
-        } catch (e) {
-            //assert.ok(false);
-        }
-        assert.ok(true);
-    });
+QUnit.test("List", function (assert) {
+  const listTestInput: number[] = [1, 2, 3];
+  assert.ok(client.testList(listTestInput), listTestInput);
+});
 
+QUnit.test("Enum", function (assert) {
+  assert.equal(client.testEnum(ThriftTest.Numberz.ONE), ThriftTest.Numberz.ONE);
+});
 
-QUnit.module('Insanity');
+QUnit.test("TypeDef", function (assert) {
+  assert.equal(client.testTypedef(new Int64(69)), 69);
+});
 
-    const crazy: ThriftTest.Insanity = {
-        'userMap': { '5': new Int64(5), '8': new Int64(8) },
-        'xtructs': [{
-            'string_thing': 'Goodbye4',
-            'byte_thing': 4,
-            'i32_thing': 4,
-            'i64_thing': new Int64(4)
-        },
-        {
-            'string_thing': 'Hello2',
-            'byte_thing': 2,
-            'i32_thing': 2,
-            'i64_thing': new Int64(2)
-        }]
-    };
-    QUnit.test('testInsanity', function(assert) {
-        const insanity: {[k: number]: (ThriftTest.Insanity | {[k:number]: ThriftTest.Insanity})} = {
-            '1': {
-                '2': crazy,
-                '3': crazy
-            },
-            '2': { '6': new ThriftTest.Insanity() }
-        };
-        const res = client.testInsanity(new ThriftTest.Insanity(crazy));
-        assert.ok(res, JSONInt64.stringify(res));
-        assert.ok(insanity, JSONInt64.stringify(insanity));
-    
-        checkRecursively(assert, res, insanity);
-    });
+QUnit.module("deeper!");
 
+QUnit.test("MapMap", function (assert) {
+  const mapMapTestExpectedResult: { [K: number]: { [k: number]: number } } = {
+    "4": { "1": 1, "2": 2, "3": 3, "4": 4 },
+    "-4": { "-4": -4, "-3": -3, "-2": -2, "-1": -1 },
+  };
+
+  const mapMapTestOutput = client.testMapMap(1);
+
+  for (let key in mapMapTestOutput) {
+    for (let key2 in mapMapTestOutput[key]) {
+      assert.equal(
+        mapMapTestOutput[key][key2],
+        mapMapTestExpectedResult[key][key2],
+      );
+    }
+  }
+
+  checkRecursively(assert, mapMapTestOutput, mapMapTestExpectedResult);
+});
+
+QUnit.module("Exception");
+
+QUnit.test("Xception", function (assert) {
+  assert.expect(2);
+  const done = assert.async();
+  try {
+    client.testException("Xception");
+    assert.ok(false);
+  } catch (e) {
+    assert.equal(e.errorCode, 1001);
+    assert.equal(e.message, "Xception");
+    done();
+  }
+});
+
+QUnit.test("no Exception", function (assert) {
+  assert.expect(1);
+  try {
+    client.testException("no Exception");
+    assert.ok(true);
+  } catch (e) {
+    assert.ok(false);
+  }
+});
+
+QUnit.test("TException", function (assert) {
+  //ThriftTest does not list TException as a legal exception so it will
+  // generate an exception on the server that does not propagate back to
+  // the client. This test has been modified to equate to "no exception"
+  assert.expect(1);
+  try {
+    client.testException("TException");
+  } catch (e) {
+    //assert.ok(false);
+  }
+  assert.ok(true);
+});
+
+QUnit.module("Insanity");
+
+const crazy: ThriftTest.Insanity = {
+  userMap: { "5": new Int64(5), "8": new Int64(8) },
+  xtructs: [
+    {
+      string_thing: "Goodbye4",
+      byte_thing: 4,
+      i32_thing: 4,
+      i64_thing: new Int64(4),
+    },
+    {
+      string_thing: "Hello2",
+      byte_thing: 2,
+      i32_thing: 2,
+      i64_thing: new Int64(2),
+    },
+  ],
+};
+QUnit.test("testInsanity", function (assert) {
+  const insanity: {
+    [k: number]: ThriftTest.Insanity | { [k: number]: ThriftTest.Insanity };
+  } = {
+    "1": {
+      "2": crazy,
+      "3": crazy,
+    },
+    "2": { "6": new ThriftTest.Insanity() },
+  };
+  const res = client.testInsanity(new ThriftTest.Insanity(crazy));
+  assert.ok(res, JSONInt64.stringify(res));
+  assert.ok(insanity, JSONInt64.stringify(insanity));
+
+  checkRecursively(assert, res, insanity);
+});
 
 //////////////////////////////////
 //Run same tests asynchronously
 
-QUnit.module('Async');
+QUnit.module("Async");
 
-    QUnit.test('Double', function(assert) {
-        assert.expect(1);
+QUnit.test("Double", function (assert) {
+  assert.expect(1);
 
-        const done = assert.async();
-        client.testDouble(3.14159265, function(result) {
-            assert.equal(result, 3.14159265);
-            done();
-        });
-    });
+  const done = assert.async();
+  client.testDouble(3.14159265, function (result) {
+    assert.equal(result, 3.14159265);
+    done();
+  });
+});
 
-    QUnit.test('Byte', function(assert) {
-        assert.expect(1);
+QUnit.test("Byte", function (assert) {
+  assert.expect(1);
 
-        const done = assert.async();
-        client.testByte(0x01, function(result) {
-            assert.equal(result, 0x01);
-            done();
-        });
-    });
+  const done = assert.async();
+  client.testByte(0x01, function (result) {
+    assert.equal(result, 0x01);
+    done();
+  });
+});
 
-    QUnit.test('I32', function(assert) {
-        assert.expect(2);
+QUnit.test("I32", function (assert) {
+  assert.expect(2);
 
-        const done = assert.async(2);
-        client.testI32(Math.pow(2, 30), function(result) {
-            assert.equal(result, Math.pow(2, 30));
-            done();
-        });
+  const done = assert.async(2);
+  client.testI32(Math.pow(2, 30), function (result) {
+    assert.equal(result, Math.pow(2, 30));
+    done();
+  });
 
-        client.testI32(Math.pow(-2, 31), function(result) {
-            assert.equal(result, Math.pow(-2, 31));
-            done();
-        });
-    });
+  client.testI32(Math.pow(-2, 31), function (result) {
+    assert.equal(result, Math.pow(-2, 31));
+    done();
+  });
+});
 
-    QUnit.test('I64', function(assert) {
-        assert.expect(2);
+QUnit.test("I64", function (assert) {
+  assert.expect(2);
 
-        const done = assert.async(2);
-        client.testI64(int64_2_pow_60, function(result) {
-            assert.ok(int64_2_pow_60.equals(result));
-            done();
-        });
+  const done = assert.async(2);
+  client.testI64(int64_2_pow_60, function (result) {
+    assert.ok(int64_2_pow_60.equals(result));
+    done();
+  });
 
-        client.testI64(int64_minus_2_pow_60, function(result) {
-            assert.ok(int64_minus_2_pow_60.equals(result));
-            done();
-        });
-    });
+  client.testI64(int64_minus_2_pow_60, function (result) {
+    assert.ok(int64_minus_2_pow_60.equals(result));
+    done();
+  });
+});
diff --git a/lib/ts/test/test_handler.js b/lib/ts/test/test_handler.js
index 8ba296b..825c567 100644
--- a/lib/ts/test/test_handler.js
+++ b/lib/ts/test/test_handler.js
@@ -20,87 +20,87 @@
 //This is the server side Node test handler for the standard
 //  Apache Thrift test service.
 
-const es6Mode = process.argv.includes('--es6');
-const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
+const es6Mode = process.argv.includes("--es6");
+const genFolder = es6Mode ? "gen-nodejs-es6" : "gen-nodejs";
 const ttypes = require(`./${genFolder}/ThriftTest_types`);
-const TException = require('../../nodejs/lib/thrift').TException;
-const Int64 = require('node-int64');
+const TException = require("../../nodejs/lib/thrift").TException;
+const Int64 = require("node-int64");
 
 exports.ThriftTestHandler = {
-  testVoid: function(result) {
-    console.log('testVoid()');
+  testVoid: function (result) {
+    console.log("testVoid()");
     result(null);
   },
-  testString: function(thing, result) {
-    console.log('testString(\'' + thing + '\')');
+  testString: function (thing, result) {
+    console.log("testString('" + thing + "')");
     result(null, thing);
   },
-  testByte: function(thing, result) {
-    console.log('testByte(' + thing + ')');
+  testByte: function (thing, result) {
+    console.log("testByte(" + thing + ")");
     result(null, thing);
   },
-  testI32: function(thing, result) {
-    console.log('testI32(' + thing + ')');
+  testI32: function (thing, result) {
+    console.log("testI32(" + thing + ")");
     result(null, thing);
   },
-  testI64: function(thing, result) {
-    console.log('testI64(' + thing + ')');
+  testI64: function (thing, result) {
+    console.log("testI64(" + thing + ")");
     result(null, thing);
   },
-  testDouble: function(thing, result) {
-    console.log('testDouble(' + thing + ')');
+  testDouble: function (thing, result) {
+    console.log("testDouble(" + thing + ")");
     result(null, thing);
   },
-  testBinary: function(thing, result) {
-    console.log('testBinary(\'' + thing + '\')');
+  testBinary: function (thing, result) {
+    console.log("testBinary('" + thing + "')");
     result(null, thing);
   },
-  testStruct: function(thing, result) {
-    console.log('testStruct(');
+  testStruct: function (thing, result) {
+    console.log("testStruct(");
     console.log(thing);
-    console.log(')');
+    console.log(")");
     result(null, thing);
   },
-  testNest: function(nest, result) {
-    console.log('testNest(');
+  testNest: function (nest, result) {
+    console.log("testNest(");
     console.log(nest);
-    console.log(')');
+    console.log(")");
     result(null, nest);
   },
-  testMap: function(thing, result) {
-    console.log('testMap(');
+  testMap: function (thing, result) {
+    console.log("testMap(");
     console.log(thing);
-    console.log(')');
+    console.log(")");
     result(null, thing);
   },
-  testStringMap: function(thing, result) {
-    console.log('testStringMap(');
+  testStringMap: function (thing, result) {
+    console.log("testStringMap(");
     console.log(thing);
-    console.log(')');
+    console.log(")");
     result(null, thing);
   },
-  testSet: function(thing, result) {
-    console.log('testSet(');
+  testSet: function (thing, result) {
+    console.log("testSet(");
     console.log(thing);
-    console.log(')');
+    console.log(")");
     result(null, thing);
   },
-  testList: function(thing, result) {
-    console.log('testList(');
+  testList: function (thing, result) {
+    console.log("testList(");
     console.log(thing);
-    console.log(')');
+    console.log(")");
     result(null, thing);
   },
-  testEnum: function(thing, result) {
-    console.log('testEnum(' + thing + ')');
+  testEnum: function (thing, result) {
+    console.log("testEnum(" + thing + ")");
     result(null, thing);
   },
-  testTypedef: function(thing, result) {
-    console.log('testTypedef(' + thing + ')');
+  testTypedef: function (thing, result) {
+    console.log("testTypedef(" + thing + ")");
     result(null, thing);
   },
-  testMapMap: function(hello, result) {
-    console.log('testMapMap(' + hello + ')');
+  testMapMap: function (hello, result) {
+    console.log("testMapMap(" + hello + ")");
 
     const mapmap = [];
     const pos = [];
@@ -114,19 +114,19 @@
 
     result(null, mapmap);
   },
-  testInsanity: function(argument, result) {
-    console.log('testInsanity(');
+  testInsanity: function (argument, result) {
+    console.log("testInsanity(");
     console.log(argument);
-    console.log(')');
+    console.log(")");
 
     const hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
+    hello.string_thing = "Hello2";
     hello.byte_thing = 2;
     hello.i32_thing = 2;
     hello.i64_thing = new Int64(2);
 
     const goodbye = new ttypes.Xtruct();
-    goodbye.string_thing = 'Goodbye4';
+    goodbye.string_thing = "Goodbye4";
     goodbye.byte_thing = 4;
     goodbye.i32_thing = 4;
     goodbye.i64_thing = new Int64(4);
@@ -150,45 +150,45 @@
     insane[1] = first_map;
     insane[2] = second_map;
 
-    console.log('insane result:');
+    console.log("insane result:");
     console.log(insane);
     result(null, insane);
   },
-  testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
-    console.log('testMulti()');
+  testMulti: function (arg0, arg1, arg2, arg3, arg4, arg5, result) {
+    console.log("testMulti()");
 
     const hello = new ttypes.Xtruct();
-    hello.string_thing = 'Hello2';
+    hello.string_thing = "Hello2";
     hello.byte_thing = arg0;
     hello.i32_thing = arg1;
     hello.i64_thing = arg2;
     result(null, hello);
   },
-  testException: function(arg, result) {
-    console.log('testException(' + arg + ')');
-    if (arg === 'Xception') {
+  testException: function (arg, result) {
+    console.log("testException(" + arg + ")");
+    if (arg === "Xception") {
       const x = new ttypes.Xception();
       x.errorCode = 1001;
       x.message = arg;
       result(x);
-    } else if (arg === 'TException') {
+    } else if (arg === "TException") {
       result(new TException(arg));
     } else {
       result(null);
     }
   },
-  testMultiException: function(arg0, arg1, result) {
-    console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
-    if (arg0 === ('Xception')) {
+  testMultiException: function (arg0, arg1, result) {
+    console.log("testMultiException(" + arg0 + ", " + arg1 + ")");
+    if (arg0 === "Xception") {
       const x = new ttypes.Xception();
       x.errorCode = 1001;
-      x.message = 'This is an Xception';
+      x.message = "This is an Xception";
       result(x);
-    } else if (arg0 === ('Xception2')) {
+    } else if (arg0 === "Xception2") {
       const x2 = new ttypes.Xception2();
       x2.errorCode = 2002;
       x2.struct_thing = new ttypes.Xtruct();
-      x2.struct_thing.string_thing = 'This is an Xception2';
+      x2.struct_thing.string_thing = "This is an Xception2";
       result(x2);
     }
 
@@ -196,7 +196,9 @@
     res.string_thing = arg1;
     result(null, res);
   },
-  testOneway: function(sleepFor, result) {
-    console.log('testOneway(' + sleepFor + ') => JavaScript (like Rust) never sleeps!');
-  }
-};   //ThriftTestSvcHandler
+  testOneway: function (sleepFor, result) {
+    console.log(
+      "testOneway(" + sleepFor + ") => JavaScript (like Rust) never sleeps!",
+    );
+  },
+}; //ThriftTestSvcHandler
diff --git a/lib/ts/thrift.d.ts b/lib/ts/thrift.d.ts
index 0ba46c9..8e9d565 100644
--- a/lib/ts/thrift.d.ts
+++ b/lib/ts/thrift.d.ts
@@ -29,7 +29,7 @@
    * @property {number}  VOID   - No value (only legal for return types).
    * @property {number}  BOOL   - True/False integer.
    * @property {number}  BYTE   - Signed 8 bit integer.
-   * @property {number}  I08    - Signed 8 bit integer.     
+   * @property {number}  I08    - Signed 8 bit integer.
    * @property {number}  DOUBLE - 64 bit IEEE 854 floating point.
    * @property {number}  I16    - Signed 16 bit integer.
    * @property {number}  I32    - Signed 32 bit integer.
@@ -44,23 +44,23 @@
    * @property {number}  UTF16  - Array of bytes representing a string of UTF16 encoded characters.
    */
   interface Type {
-    'STOP': number;
-    'VOID': number;
-    'BOOL': number;
-    'BYTE': number;
-    'I08': number;
-    'DOUBLE': number;
-    'I16': number;
-    'I32': number;
-    'I64': number;
-    'STRING': number;
-    'UTF7': number;
-    'STRUCT': number;
-    'MAP': number;
-    'SET': number;
-    'LIST': number;
-    'UTF8': number;
-    'UTF16': number;
+    STOP: number;
+    VOID: number;
+    BOOL: number;
+    BYTE: number;
+    I08: number;
+    DOUBLE: number;
+    I16: number;
+    I32: number;
+    I64: number;
+    STRING: number;
+    UTF7: number;
+    STRUCT: number;
+    MAP: number;
+    SET: number;
+    LIST: number;
+    UTF8: number;
+    UTF16: number;
   }
   var Type: Type;
 
@@ -72,10 +72,10 @@
    * @property {number}  ONEWAY    - Oneway RPC call from client to server with no response.
    */
   interface MessageType {
-    'CALL': number;
-    'REPLY': number;
-    'EXCEPTION': number;
-    'ONEWAY': number;
+    CALL: number;
+    REPLY: number;
+    EXCEPTION: number;
+    ONEWAY: number;
   }
   var MessageType: MessageType;
 
@@ -92,7 +92,11 @@
    * @param {function} superConstructor - Contstructor function to set as base.
    * @param {string} [name] - Type name to set as name property in derived prototype.
    */
-  function inherits(constructor: Function, superConstructor: Function, name?: string): void;
+  function inherits(
+    constructor: Function,
+    superConstructor: Function,
+    name?: string,
+  ): void;
 
   /**
    * TException is the base class for all Thrift exceptions types.
@@ -129,17 +133,17 @@
    * @property {number}  UNSUPPORTED_CLIENT_TYPE - Unused.
    */
   interface TApplicationExceptionType {
-    'UNKNOWN': number;
-    'UNKNOWN_METHOD': number;
-    'INVALID_MESSAGE_TYPE': number;
-    'WRONG_METHOD_NAME': number;
-    'BAD_SEQUENCE_ID': number;
-    'MISSING_RESULT': number;
-    'INTERNAL_ERROR': number;
-    'PROTOCOL_ERROR': number;
-    'INVALID_TRANSFORM': number;
-    'INVALID_PROTOCOL': number;
-    'UNSUPPORTED_CLIENT_TYPE': number;
+    UNKNOWN: number;
+    UNKNOWN_METHOD: number;
+    INVALID_MESSAGE_TYPE: number;
+    WRONG_METHOD_NAME: number;
+    BAD_SEQUENCE_ID: number;
+    MISSING_RESULT: number;
+    INTERNAL_ERROR: number;
+    PROTOCOL_ERROR: number;
+    INVALID_TRANSFORM: number;
+    INVALID_PROTOCOL: number;
+    UNSUPPORTED_CLIENT_TYPE: number;
   }
   var TApplicationExceptionType: TApplicationExceptionType;
 
@@ -179,7 +183,7 @@
   /**
    * The Apache Thrift Transport layer performs byte level I/O between RPC
    * clients and servers. The JavaScript Transport object type uses Http[s]/XHR and is
-   * the sole browser based Thrift transport. Target servers must implement the http[s] 
+   * the sole browser based Thrift transport. Target servers must implement the http[s]
    * transport (see: node.js example server).
    */
   class TXHRTransport {
@@ -208,7 +212,7 @@
     /**
      * Sends the current XRH request if the transport was created with a URL and
      * the async parameter if false. If the transport was not created with a URL
-     * or the async parameter is True or the URL is an empty string, the current 
+     * or the async parameter is True or the URL is an empty string, the current
      * send buffer is returned.
      * @param {object} async - If true the current send buffer is returned.
      * @param {function} callback - Optional async completion callback.
@@ -224,7 +228,12 @@
      * @param {function} recv_method - The Thrift Service Client receive method for the call.
      * @returns {object} A new jQuery XHR object.
      */
-    jqRequest(client: Object, postData: any, args: Function, recv_method: Function): Object;
+    jqRequest(
+      client: Object,
+      postData: any,
+      args: Function,
+      recv_method: Function,
+    ): Object;
 
     /**
      * Sets the buffer to use when receiving server responses.
@@ -281,22 +290,22 @@
   /**
    * Old alias of the TXHRTransport for backwards compatibility.
    */
-  class Transport extends TXHRTransport { }
+  class Transport extends TXHRTransport {}
 
   /**
-   * The Apache Thrift Transport layer performs byte level I/O 
-   * between RPC clients and servers. The JavaScript TWebSocketTransport object 
+   * The Apache Thrift Transport layer performs byte level I/O
+   * between RPC clients and servers. The JavaScript TWebSocketTransport object
    * uses the WebSocket protocol. Target servers must implement WebSocket.
    */
   class TWebSocketTransport {
-    url: string;           //Where to connect
-    socket: any;           //The web socket
+    url: string; //Where to connect
+    socket: any; //The web socket
     callbacks: Function[]; //Pending callbacks
-    send_pending: any[];   //Buffers/Callback pairs waiting to be sent
-    send_buf: string;      //Outbound data, immutable until sent
-    recv_buf: string;      //Inbound data
-    rb_wpos: number;       //Network write position in receive buffer
-    rb_rpos: number;       //Client read position in receive buffer
+    send_pending: any[]; //Buffers/Callback pairs waiting to be sent
+    send_buf: string; //Outbound data, immutable until sent
+    recv_buf: string; //Inbound data
+    rb_wpos: number; //Network write position in receive buffer
+    rb_rpos: number; //Client read position in receive buffer
 
     /**
      * Constructor Function for the WebSocket transport.
@@ -307,12 +316,12 @@
     __reset(url: string): void;
 
     /**
-     * Sends the current WS request and registers callback. The async 
-     * parameter is ignored (WS flush is always async) and the callback 
+     * Sends the current WS request and registers callback. The async
+     * parameter is ignored (WS flush is always async) and the callback
      * function parameter is required.
      * @param {object} async - Ignored.
      * @param {function} callback - The client completion callback.
-     * @returns {undefined|string} Nothing (undefined) 
+     * @returns {undefined|string} Nothing (undefined)
      */
     flush(async: any, callback: Function): string;
 
@@ -332,7 +341,7 @@
 
     /**
      * Returns true if the transport is open
-     * @returns {boolean} 
+     * @returns {boolean}
      */
     isOpen(): boolean;
 
@@ -374,8 +383,8 @@
   }
 
   /**
-   * Apache Thrift Protocols perform serialization which enables cross 
-   * language RPC. The Protocol type is the JavaScript browser implementation 
+   * Apache Thrift Protocols perform serialization which enables cross
+   * language RPC. The Protocol type is the JavaScript browser implementation
    * of the Apache Thrift TJSONProtocol.
    */
   class TJSONProtocol {
@@ -401,17 +410,17 @@
     /**
      * Thrift IDL type string to Id mapping.
      * The mapping table looks as follows:
-     * "tf"  -> Thrift.Type.BOOL  
-     * "i8"  -> Thrift.Type.BYTE  
-     * "i16" -> Thrift.Type.I16   
-     * "i32" -> Thrift.Type.I32   
-     * "i64" -> Thrift.Type.I64   
+     * "tf"  -> Thrift.Type.BOOL
+     * "i8"  -> Thrift.Type.BYTE
+     * "i16" -> Thrift.Type.I16
+     * "i32" -> Thrift.Type.I32
+     * "i64" -> Thrift.Type.I64
      * "dbl" -> Thrift.Type.DOUBLE
      * "rec" -> Thrift.Type.STRUCT
      * "str" -> Thrift.Type.STRING
-     * "map" -> Thrift.Type.MAP   
-     * "lst" -> Thrift.Type.LIST  
-     * "set" -> Thrift.Type.SET   
+     * "map" -> Thrift.Type.MAP
+     * "lst" -> Thrift.Type.LIST
+     * "set" -> Thrift.Type.SET
      */
     RType: { [k: string]: number };
 
@@ -542,8 +551,8 @@
        @property {Thrift.MessageType} mtype - The type of message call.
        @property {number} rseqid - The sequence number of the message (0 in Thrift RPC).
      */
-    /** 
-     * Deserializes the beginning of a message. 
+    /**
+     * Deserializes the beginning of a message.
      * @returns {AnonReadMessageBeginReturn}
      */
     readMessageBegin(): { fname: string; mtype: number; rseqid: number };
@@ -551,8 +560,8 @@
     /** Deserializes the end of a message. */
     readMessageEnd(): void;
 
-    /** 
-     * Deserializes the beginning of a struct. 
+    /**
+     * Deserializes the beginning of a struct.
      * @param {string} [name] - The name of the struct (ignored).
      * @returns {object} - An object with an empty string fname property.
      */
@@ -568,8 +577,8 @@
        @property {Thrift.Type} ftype - The data type of the field.
        @property {number} fid - The unique identifier of the field.
      */
-    /** 
-     * Deserializes the beginning of a field. 
+    /**
+     * Deserializes the beginning of a field.
      * @returns {AnonReadFieldBeginReturn}
      */
     readFieldBegin(): { fname: string; ftype: number; fid: number };
@@ -584,8 +593,8 @@
        @property {Thrift.Type} vtype - The data type of the value.
        @property {number} size - The number of elements in the map.
      */
-    /** 
-     * Deserializes the beginning of a map. 
+    /**
+     * Deserializes the beginning of a map.
      * @returns {AnonReadMapBeginReturn}
      */
     readMapBegin(): { ktype: number; vtype: number; size: number };
@@ -599,8 +608,8 @@
        @property {Thrift.Type} etype - The data type of the element.
        @property {number} size - The number of elements in the collection.
      */
-    /** 
-     * Deserializes the beginning of a list. 
+    /**
+     * Deserializes the beginning of a list.
      * @returns {AnonReadColBeginReturn}
      */
     readListBegin(): { etype: number; size: number };
@@ -608,19 +617,22 @@
     /** Deserializes the end of a list. */
     readListEnd(): void;
 
-    /** 
-     * Deserializes the beginning of a set. 
+    /**
+     * Deserializes the beginning of a set.
      * @param {Thrift.Type} elemType - The data type of the elements (ignored).
      * @param {number} size - The number of elements in the list (ignored).
      * @returns {AnonReadColBeginReturn}
      */
-    readSetBegin(elemType?: number, size?: number): { etype: number; size: number };
+    readSetBegin(
+      elemType?: number,
+      size?: number,
+    ): { etype: number; size: number };
 
     /** Deserializes the end of a set. */
     readSetEnd(): void;
 
-    /** Returns an object with a value property set to 
-     *  False unless the next number in the protocol buffer 
+    /** Returns an object with a value property set to
+     *  False unless the next number in the protocol buffer
      *  is 1, in which case the value property is True. */
     readBool(): Object;
 
@@ -652,7 +664,7 @@
         next value found in the protocol buffer. */
     readBinary(): Object;
 
-    /** 
+    /**
      * Method to arbitrarily skip over data (not implemented).
      */
     skip(type: number): void;
@@ -661,7 +673,7 @@
   /**
    * Old alias of the TXHRTransport for backwards compatibility.
    */
-  class Protocol extends TJSONProtocol { }
+  class Protocol extends TJSONProtocol {}
 
   class MultiplexProtocol extends TJSONProtocol {
     serviceName: string;
@@ -673,7 +685,12 @@
      * @param {any} [strictRead]
      * @param {any} [strictWrite]
      */
-    constructor(srvName: string, trans: Object, strictRead?: any, strictWrite?: any);
+    constructor(
+      srvName: string,
+      trans: Object,
+      strictRead?: any,
+      strictWrite?: any,
+    );
 
     /**
      * Override writeMessageBegin method of prototype