From be787d09d537d6c1a6846168613dd0defe069448 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Wed, 26 Feb 2020 07:33:19 +1100 Subject: upgrade: TypeScript 3.8 (#4100) --- cli/js/compiler_util.ts | 9 +++++++-- cli/tests/integration_tests.rs | 42 +++++++++++++++++++++++++++++++++++++++ cli/tests/subdir/amd_like.js | 1 - cli/tests/subdir/single_module.ts | 2 +- cli/tests/subdir/tla.ts | 1 + 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 cli/tests/subdir/tla.ts (limited to 'cli') diff --git a/cli/js/compiler_util.ts b/cli/js/compiler_util.ts index 8a043d7d1..9dd245413 100644 --- a/cli/js/compiler_util.ts +++ b/cli/js/compiler_util.ts @@ -270,11 +270,16 @@ export function convertCompilerOptions(str: string): ts.CompilerOptions { /** An array of TypeScript diagnostic types we ignore. */ export const ignoredDiagnostics = [ + // TS2306: File 'file:///Users/rld/src/deno/cli/tests/subdir/amd_like.js' is + // not a module. + 2306, + // TS1375: 'await' expressions are only allowed at the top level of a file + // when that file is a module, but this file has no imports or exports. + // Consider adding an empty 'export {}' to make this file a module. + 1375, // TS1103: 'for-await-of' statement is only allowed within an async function // or async generator. 1103, - // TS1308: 'await' expression is only allowed within an async function. - 1308, // TS2691: An import path cannot end with a '.ts' extension. Consider // importing 'bad-module' instead. 2691, diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 3e2c28980..20de4b030 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -326,6 +326,48 @@ fn bundle_single_module() { assert_eq!(output.stderr, b""); } +#[test] +fn bundle_tla() { + // First we have to generate a bundle of some module that has exports. + let tla_import = util::root_path().join("cli/tests/subdir/tla.ts"); + assert!(tla_import.is_file()); + let t = tempfile::TempDir::new().expect("tempdir fail"); + let bundle = t.path().join("tla.bundle.js"); + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("bundle") + .arg(tla_import) + .arg(&bundle) + .spawn() + .expect("failed to spawn script"); + let status = deno.wait().expect("failed to wait for the child process"); + assert!(status.success()); + assert!(bundle.is_file()); + + // Now we try to use that bundle from another module. + let test = t.path().join("test.js"); + std::fs::write( + &test, + " + import { foo } from \"./tla.bundle.js\"; + console.log(foo); ", + ) + .expect("error writing file"); + + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg(&test) + .output() + .expect("failed to spawn script"); + // check the output of the test.ts program. + assert!(std::str::from_utf8(&output.stdout) + .unwrap() + .trim() + .ends_with("Hello")); + assert_eq!(output.stderr, b""); +} + #[test] fn repl_test_console_log() { let (out, err, code) = diff --git a/cli/tests/subdir/amd_like.js b/cli/tests/subdir/amd_like.js index 23babc4db..f27e505e4 100644 --- a/cli/tests/subdir/amd_like.js +++ b/cli/tests/subdir/amd_like.js @@ -1,4 +1,3 @@ // looks like an AMD module, but isn't const define = () => {}; define(["fake_module"], () => {}); -export {}; diff --git a/cli/tests/subdir/single_module.ts b/cli/tests/subdir/single_module.ts index 1cd2cd781..f41b0a4b5 100644 --- a/cli/tests/subdir/single_module.ts +++ b/cli/tests/subdir/single_module.ts @@ -1,2 +1,2 @@ console.log("Hello world!"); -export {}; +export {}; // TODO(ry) This shouldn't be necessary. diff --git a/cli/tests/subdir/tla.ts b/cli/tests/subdir/tla.ts new file mode 100644 index 000000000..713dbfca0 --- /dev/null +++ b/cli/tests/subdir/tla.ts @@ -0,0 +1 @@ +export const foo = await Promise.resolve("Hello"); -- cgit v1.2.3