diff --git a/.gitignore b/.gitignore
index c6c3067a3e96b4364f5e1badf30c57ab75220f3d..aedeb3cb2498b8c4d7f74cc18af9cf3ada7d728d 100755
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@ tests/monsterdata_java_wire.mon
 tests/monsterdata_go_wire.mon
 tests/monsterdata_javascript_wire.mon
 tests/unicode_test.mon
+tests/ts/
 CMakeLists.txt.user
 CMakeScripts/**
 CTestTestfile.cmake
diff --git a/appveyor.yml b/appveyor.yml
index 57f65e348fe27428308c287b86b3f320ad389663..f350f0664513ff2f73243ab551736961ea938ef6 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -31,7 +31,7 @@ test_script:
   - rem "---------------- JS -----------------"
   - "node --version"
   - "..\\%CONFIGURATION%\\flatc -b monster_test.fbs unicode_test.json"
-  - "node JavaScriptTest"
+  - "node JavaScriptTest ./monster_test_generated"
   - rem "---------------- C# -----------------"
   # Have to compile this here rather than in "build" above because AppVeyor only
   # supports building one project??
diff --git a/tests/JavaScriptTest.js b/tests/JavaScriptTest.js
index c656974e7f921645e565aa7257c60c25d5cb52b2..7ed313af40e454d7d305a51b1f385d82200bc211 100644
--- a/tests/JavaScriptTest.js
+++ b/tests/JavaScriptTest.js
@@ -3,7 +3,7 @@ var assert = require('assert');
 var fs = require('fs');
 
 var flatbuffers = require('../js/flatbuffers').flatbuffers;
-var MyGame = require('./monster_test_generated').MyGame;
+var MyGame = require(process.argv[2]).MyGame;
 
 function main() {
 
diff --git a/tests/JavaScriptTest.sh b/tests/JavaScriptTest.sh
index 75db007879ab47336534734dad82b42d4a90c218..cdba5fa69b1ce00da56c5fa8e00bd46201d66943 100755
--- a/tests/JavaScriptTest.sh
+++ b/tests/JavaScriptTest.sh
@@ -16,4 +16,4 @@
 
 pushd "$(dirname $0)" >/dev/null
 ../flatc -b monster_test.fbs unicode_test.json
-node JavaScriptTest
+node JavaScriptTest ./monster_test_generated
diff --git a/tests/TypeScriptTest.sh b/tests/TypeScriptTest.sh
index 4e37451c670ea4dd235d0348dbc8186706cfa7b5..a5d44d57fa9cd73561b4b4b53f046f5693dbf8cc 100755
--- a/tests/TypeScriptTest.sh
+++ b/tests/TypeScriptTest.sh
@@ -15,11 +15,9 @@
 # limitations under the License.
 
 pushd "$(dirname $0)" >/dev/null
-../flatc --ts --no-fb-import --gen-mutable monster_test.fbs
+../flatc --ts --no-fb-import --gen-mutable -o ts monster_test.fbs
 ../flatc -b monster_test.fbs unicode_test.json
 npm install @types/flatbuffers
-mv monster_test_generated.js monster_test_generated.js.bak
-tsc monster_test_generated.ts
+tsc ts/monster_test_generated.ts
 npm uninstall @types/flatbuffers
-node JavaScriptTest
-mv monster_test_generated.js.bak monster_test_generated.js
+node JavaScriptTest ./ts/monster_test_generated
diff --git a/tests/generate_code.sh b/tests/generate_code.sh
index b12e78a76ae4ec02331af7f5b6e237953bb1566d..bdce8405d498f442bb58caf635cf3326d64d58e5 100755
--- a/tests/generate_code.sh
+++ b/tests/generate_code.sh
@@ -14,8 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-../flatc --cpp --java --csharp --go --binary --python --js --ts --php --grpc --gen-mutable --gen-object-api --no-includes monster_test.fbs monsterdata_test.json
-../flatc --cpp --java --csharp --go --binary --python --js --ts --php --gen-mutable -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
+../flatc --cpp --java --csharp --go --binary --python --js --ts --php --grpc --gen-mutable --gen-object-api --no-includes --no-fb-import monster_test.fbs monsterdata_test.json
+../flatc --cpp --java --csharp --go --binary --python --js --ts --php --gen-mutable --no-fb-import -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
 ../flatc --cpp --gen-mutable --gen-object-api -o union_vector ./union_vector/union_vector.fbs
 ../flatc -b --schema --bfbs-comments monster_test.fbs
 cd ../samples
diff --git a/tests/namespace_test/namespace_test1_generated.ts b/tests/namespace_test/namespace_test1_generated.ts
index f94d14a52e7f100e73da2a5c8b00bc5e169e773a..42a1a69184f46466d38d7cb9e9e0d5201cc4fe14 100644
--- a/tests/namespace_test/namespace_test1_generated.ts
+++ b/tests/namespace_test/namespace_test1_generated.ts
@@ -1,6 +1,5 @@
 // automatically generated by the FlatBuffers compiler, do not modify
 
-import { flatbuffers } from "./flatbuffers"
 /**
  * @enum
  */
diff --git a/tests/namespace_test/namespace_test2_generated.ts b/tests/namespace_test/namespace_test2_generated.ts
index babf8adca457ce323576a303f21e584c9837094d..d08366bd42576a656690ea223fdb5be2f4fcb93c 100644
--- a/tests/namespace_test/namespace_test2_generated.ts
+++ b/tests/namespace_test/namespace_test2_generated.ts
@@ -1,8 +1,6 @@
 // automatically generated by the FlatBuffers compiler, do not modify
 
-import { flatbuffers } from "./flatbuffers"
 import * as NS9459827973991502386 from "./namespace_test1_generated";
-export * from "./namespace_test1_generated";
 /**
  * @constructor
  */