From 43d10a558b72ef4a079358521d22447d095e0097 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 9 Jul 2024 17:07:16 -0400 Subject: [PATCH] fix: do not download compilerOptions -> types when not type checking (#24473) Closes https://github.com/denoland/deno/issues/22738 --- cli/args/mod.rs | 4 +--- cli/graph_util.rs | 6 +++++- .../specs/run/skips_compiler_option_types/__test__.jsonc | 6 ++++++ tests/specs/run/skips_compiler_option_types/deno.json | 8 ++++++++ tests/specs/run/skips_compiler_option_types/main.out | 1 + tests/specs/run/skips_compiler_option_types/main.ts | 1 + 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 tests/specs/run/skips_compiler_option_types/__test__.jsonc create mode 100644 tests/specs/run/skips_compiler_option_types/deno.json create mode 100644 tests/specs/run/skips_compiler_option_types/main.out create mode 100644 tests/specs/run/skips_compiler_option_types/main.ts diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 04a0111961..e0eff6171d 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1301,9 +1301,7 @@ impl CliOptions { self.maybe_lockfile.clone() } - /// Return any imports that should be brought into the scope of the module - /// graph. - pub fn to_maybe_imports( + pub fn to_compiler_option_types( &self, ) -> Result, AnyError> { self.workspace.to_maybe_imports().map(|maybe_imports| { diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 2f9ee8d93d..7f664420c5 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -481,7 +481,11 @@ impl ModuleGraphBuilder { } } - let maybe_imports = self.options.to_maybe_imports()?; + let maybe_imports = if options.graph_kind.include_types() { + self.options.to_compiler_option_types()? + } else { + Vec::new() + }; let analyzer = self .module_info_cache .as_module_analyzer(&self.parsed_source_cache); diff --git a/tests/specs/run/skips_compiler_option_types/__test__.jsonc b/tests/specs/run/skips_compiler_option_types/__test__.jsonc new file mode 100644 index 0000000000..bd2d5aaa2f --- /dev/null +++ b/tests/specs/run/skips_compiler_option_types/__test__.jsonc @@ -0,0 +1,6 @@ +{ + // this was previously downloading the "types" from the compilerOptions + // even for deno run with no type checking + "args": "run main.ts", + "output": "main.out" +} diff --git a/tests/specs/run/skips_compiler_option_types/deno.json b/tests/specs/run/skips_compiler_option_types/deno.json new file mode 100644 index 0000000000..92d0923b99 --- /dev/null +++ b/tests/specs/run/skips_compiler_option_types/deno.json @@ -0,0 +1,8 @@ +{ + "lock": false, + "compilerOptions": { + "types": [ + "https://localhost@4545/non-existent/@types/react@18.0.28" + ] + } +} diff --git a/tests/specs/run/skips_compiler_option_types/main.out b/tests/specs/run/skips_compiler_option_types/main.out new file mode 100644 index 0000000000..45b983be36 --- /dev/null +++ b/tests/specs/run/skips_compiler_option_types/main.out @@ -0,0 +1 @@ +hi diff --git a/tests/specs/run/skips_compiler_option_types/main.ts b/tests/specs/run/skips_compiler_option_types/main.ts new file mode 100644 index 0000000000..d914c6066c --- /dev/null +++ b/tests/specs/run/skips_compiler_option_types/main.ts @@ -0,0 +1 @@ +console.log("hi");