diff --git a/test/test_other.py b/test/test_other.py index 2513616c964c7..00a047e419a6e 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -345,6 +345,11 @@ def run_on_pty(self, cmd): os.close(master) os.close(slave) + def run_tsc(self, args): + # We use skipLibCheck to prevent tsc from type checking the node_modules in the parent directory + # (e.g. in a single test mode). + return self.run_process(shared.get_npm_cmd('tsc') + ['--skipLibCheck'] + args) + # Test that running `emcc -v` always works even in the presence of `EMCC_CFLAGS`. # This needs to work because many tools run `emcc -v` internally and it should # always work even if the user has `EMCC_CFLAGS` set. @@ -3566,8 +3571,7 @@ def test_embind_tsgen_end_to_end(self, opts, tsc_opts): # also run the output JS file as a module in node. copy_asset('other/embind_tsgen_package.json', 'package.json') - cmd = shared.get_npm_cmd('tsc') + ['embind_tsgen.d.ts', 'main.ts', '--target', 'es2021'] + tsc_opts - shared.check_call(cmd) + self.run_tsc(['embind_tsgen.d.ts', 'main.ts', '--target', 'es2021'] + tsc_opts) actual = read_file('embind_tsgen.d.ts') self.assertFileContents(test_file('other/embind_tsgen_module.d.ts'), actual) self.assertContained('main ran\nts ran', self.run_js('main.js')) @@ -3727,8 +3731,7 @@ def test_emit_tsd(self): self.get_cflags()) self.assertFileContents(test_file('other/test_emit_tsd.d.ts'), read_file('test_emit_tsd.d.ts')) # Test that the output compiles with a TS file that uses the definitions. - cmd = shared.get_npm_cmd('tsc') + [test_file('other/test_tsd.ts'), '--noEmit'] - shared.check_call(cmd) + self.run_tsc([test_file('other/test_tsd.ts'), '--noEmit']) @requires_dev_dependency('typescript') def test_emit_tsd_sync_compilation(self): @@ -3739,8 +3742,7 @@ def test_emit_tsd_sync_compilation(self): self.get_cflags()) self.assertFileContents(test_file('other/test_emit_tsd_sync.d.ts'), read_file('test_emit_tsd_sync.d.ts')) # Test that the output compiles with a TS file that uses the definitions. - cmd = shared.get_npm_cmd('tsc') + [test_file('other/test_tsd_sync.ts'), '--noEmit'] - shared.check_call(cmd) + self.run_tsc([test_file('other/test_tsd_sync.ts'), '--noEmit']) def test_emit_tsd_wasm_only(self): expected = 'Wasm only output is not compatible with --emit-tsd'