From f661710f203e4ced4b9bc46f69b7fa78b2582cb4 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 24 Sep 2024 20:42:48 -0400 Subject: [PATCH 1/4] fix(check): properly surface dependency errors in types file of js file --- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- cli/graph_util.rs | 12 ++++++++---- cli/lsp/language_server.rs | 2 +- cli/tools/registry/graph.rs | 2 +- .../dts_importing_non_existent/__test__.jsonc | 4 ++++ .../dts_importing_non_existent/check.out | 2 ++ .../dts_importing_non_existent/index.d.ts | 1 + .../check/dts_importing_non_existent/index.js | 1 + tests/specs/run/sloppy_imports/__test__.jsonc | 19 +++++++++++-------- tests/specs/run/sloppy_imports/sloppy.out | 1 + 11 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 tests/specs/check/dts_importing_non_existent/__test__.jsonc create mode 100644 tests/specs/check/dts_importing_non_existent/check.out create mode 100644 tests/specs/check/dts_importing_non_existent/index.d.ts create mode 100644 tests/specs/check/dts_importing_non_existent/index.js diff --git a/Cargo.lock b/Cargo.lock index 492cfa2606d60f..bec2ec12cc0282 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1584,9 +1584,9 @@ dependencies = [ [[package]] name = "deno_graph" -version = "0.82.1" +version = "0.82.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b63015c73aa203da206b5d35b4c1eaa23bc7fed37ab325da62d525a5524a04" +checksum = "9328b62ffc7e806f1c92fd7a22e4ff3046fcb53f2d46e3e1297482b2c4c2bb9d" dependencies = [ "anyhow", "async-trait", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fc3216a6062712..ec2243a818b7a7 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -68,7 +68,7 @@ deno_cache_dir = { workspace = true } deno_config = { version = "=0.35.0", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_doc = { version = "0.148.0", features = ["html", "syntect"] } -deno_graph = { version = "=0.82.1" } +deno_graph = { version = "=0.82.2" } deno_lint = { version = "=0.67.0", features = ["docs"] } deno_lockfile.workspace = true deno_npm = "=0.25.2" diff --git a/cli/graph_util.rs b/cli/graph_util.rs index cd98c3824de371..1add83eb990a0f 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -55,7 +55,7 @@ use std::sync::Arc; #[derive(Clone, Copy)] pub struct GraphValidOptions { pub check_js: bool, - pub follow_type_only: bool, + pub kind: GraphKind, pub is_vendoring: bool, /// Whether to exit the process for lockfile errors. /// Otherwise, surfaces lockfile errors as errors. @@ -84,7 +84,7 @@ pub fn graph_valid( roots.iter(), deno_graph::WalkOptions { check_js: options.check_js, - follow_type_only: options.follow_type_only, + kind: options.kind, follow_dynamic: options.is_vendoring, prefer_fast_check_graph: false, }, @@ -708,7 +708,11 @@ impl ModuleGraphBuilder { roots, GraphValidOptions { is_vendoring: false, - follow_type_only: self.options.type_check_mode().is_true(), + kind: if self.options.type_check_mode().is_true() { + GraphKind::All + } else { + GraphKind::CodeOnly + }, check_js: self.options.check_js(), exit_lockfile_errors: true, }, @@ -928,7 +932,7 @@ pub fn has_graph_root_local_dependent_changed( std::iter::once(root), deno_graph::WalkOptions { follow_dynamic: true, - follow_type_only: true, + kind: GraphKind::All, prefer_fast_check_graph: true, check_js: true, }, diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index a1cc5079d4aac6..85daa4e289bf30 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -275,7 +275,7 @@ impl LanguageServer { &roots, graph_util::GraphValidOptions { is_vendoring: false, - follow_type_only: true, + kind: GraphKind::All, check_js: false, exit_lockfile_errors: false, }, diff --git a/cli/tools/registry/graph.rs b/cli/tools/registry/graph.rs index d14e4cd845a4e4..184557e5df7797 100644 --- a/cli/tools/registry/graph.rs +++ b/cli/tools/registry/graph.rs @@ -128,7 +128,7 @@ impl GraphDiagnosticsCollector { follow_dynamic: true, // search the entire graph and not just the fast check subset prefer_fast_check_graph: false, - follow_type_only: true, + kind: deno_graph::GraphKind::All, }; let mut iter = graph.walk(graph.roots.iter(), options); while let Some((specifier, entry)) = iter.next() { diff --git a/tests/specs/check/dts_importing_non_existent/__test__.jsonc b/tests/specs/check/dts_importing_non_existent/__test__.jsonc new file mode 100644 index 00000000000000..7dd02957134036 --- /dev/null +++ b/tests/specs/check/dts_importing_non_existent/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check index.js", + "output": "check.out" +} diff --git a/tests/specs/check/dts_importing_non_existent/check.out b/tests/specs/check/dts_importing_non_existent/check.out new file mode 100644 index 00000000000000..80ec9593b07a38 --- /dev/null +++ b/tests/specs/check/dts_importing_non_existent/check.out @@ -0,0 +1,2 @@ +error: Module not found "file:///[WILDLINE]/test". + at file:///[WILDLINE]/index.d.ts:1:22 diff --git a/tests/specs/check/dts_importing_non_existent/index.d.ts b/tests/specs/check/dts_importing_non_existent/index.d.ts new file mode 100644 index 00000000000000..4216ca3ed0ddbd --- /dev/null +++ b/tests/specs/check/dts_importing_non_existent/index.d.ts @@ -0,0 +1 @@ +export { Test } from "./test"; diff --git a/tests/specs/check/dts_importing_non_existent/index.js b/tests/specs/check/dts_importing_non_existent/index.js new file mode 100644 index 00000000000000..4b2c5ecce3a02d --- /dev/null +++ b/tests/specs/check/dts_importing_non_existent/index.js @@ -0,0 +1 @@ +/// diff --git a/tests/specs/run/sloppy_imports/__test__.jsonc b/tests/specs/run/sloppy_imports/__test__.jsonc index 79aaaba69d8fa6..a992f390ba43de 100644 --- a/tests/specs/run/sloppy_imports/__test__.jsonc +++ b/tests/specs/run/sloppy_imports/__test__.jsonc @@ -1,10 +1,13 @@ { - "steps": [{ - "args": "run main.ts", - "output": "no_sloppy.out", - "exitCode": 1 - }, { - "args": "run --unstable-sloppy-imports main.ts", - "output": "sloppy.out" - }] + "tests": { + "no_sloppy": { + "args": "run --check main.ts", + "output": "no_sloppy.out", + "exitCode": 1 + }, + "sloppy": { + "args": "run --unstable-sloppy-imports --check main.ts", + "output": "sloppy.out" + } + } } diff --git a/tests/specs/run/sloppy_imports/sloppy.out b/tests/specs/run/sloppy_imports/sloppy.out index 170a4bb1674a61..3c17b7e8726d56 100644 --- a/tests/specs/run/sloppy_imports/sloppy.out +++ b/tests/specs/run/sloppy_imports/sloppy.out @@ -1,3 +1,4 @@ +Check file:///V:/deno/tests/specs/run/sloppy_imports/main.ts [class A] [class B] [class C] From d41d0c444770d3ffa2ecd31cf79e50ffeda22e2a Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 24 Sep 2024 20:57:13 -0400 Subject: [PATCH 2/4] works on my machine --- tests/specs/run/sloppy_imports/sloppy.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/specs/run/sloppy_imports/sloppy.out b/tests/specs/run/sloppy_imports/sloppy.out index 3c17b7e8726d56..85c427ba4bcbea 100644 --- a/tests/specs/run/sloppy_imports/sloppy.out +++ b/tests/specs/run/sloppy_imports/sloppy.out @@ -1,4 +1,4 @@ -Check file:///V:/deno/tests/specs/run/sloppy_imports/main.ts +Check file:///[WILDINE]/main.ts [class A] [class B] [class C] From 02d0d2c3171f390768269f2b29ebad35341ccd57 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 24 Sep 2024 21:11:39 -0400 Subject: [PATCH 3/4] fix test expectation --- tests/specs/check/dts_importing_non_existent/__test__.jsonc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/specs/check/dts_importing_non_existent/__test__.jsonc b/tests/specs/check/dts_importing_non_existent/__test__.jsonc index 7dd02957134036..3775b7fb4c5aa7 100644 --- a/tests/specs/check/dts_importing_non_existent/__test__.jsonc +++ b/tests/specs/check/dts_importing_non_existent/__test__.jsonc @@ -1,4 +1,5 @@ { "args": "check index.js", - "output": "check.out" + "output": "check.out", + "exitCode": 1 } From 90433f3536ba4114c97c633cdf913010fde4440c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 24 Sep 2024 21:29:50 -0400 Subject: [PATCH 4/4] fix expectation --- tests/specs/run/sloppy_imports/sloppy.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/specs/run/sloppy_imports/sloppy.out b/tests/specs/run/sloppy_imports/sloppy.out index 85c427ba4bcbea..2cc57b6fc3f660 100644 --- a/tests/specs/run/sloppy_imports/sloppy.out +++ b/tests/specs/run/sloppy_imports/sloppy.out @@ -1,4 +1,4 @@ -Check file:///[WILDINE]/main.ts +Check file:///[WILDLINE]/main.ts [class A] [class B] [class C]