Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(check): properly surface dependency errors in types file of js file #25860

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 8 additions & 4 deletions cli/graph_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/registry/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions tests/specs/check/dts_importing_non_existent/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "check index.js",
"output": "check.out",
"exitCode": 1
}
2 changes: 2 additions & 0 deletions tests/specs/check/dts_importing_non_existent/check.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: Module not found "file:///[WILDLINE]/test".
at file:///[WILDLINE]/index.d.ts:1:22
1 change: 1 addition & 0 deletions tests/specs/check/dts_importing_non_existent/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Test } from "./test";
1 change: 1 addition & 0 deletions tests/specs/check/dts_importing_non_existent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="./index.d.ts" />
19 changes: 11 additions & 8 deletions tests/specs/run/sloppy_imports/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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"
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was during my investigation of the issue. I decided to keep it because it's a better test.

}
1 change: 1 addition & 0 deletions tests/specs/run/sloppy_imports/sloppy.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Check file:///[WILDLINE]/main.ts
[class A]
[class B]
[class C]
Expand Down