mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(cli): do not write tsbuildinfo when diagnostics are emitted (#8311)
Fixes #8309
This commit is contained in:
parent
71d7482577
commit
293cae5e1f
3 changed files with 70 additions and 39 deletions
|
@ -800,7 +800,8 @@ impl Graph {
|
||||||
graph.maybe_tsbuildinfo = response.maybe_tsbuildinfo;
|
graph.maybe_tsbuildinfo = response.maybe_tsbuildinfo;
|
||||||
// Only process changes to the graph if there are no diagnostics and there
|
// Only process changes to the graph if there are no diagnostics and there
|
||||||
// were files emitted.
|
// were files emitted.
|
||||||
if response.diagnostics.is_empty() && !response.emitted_files.is_empty() {
|
if response.diagnostics.is_empty() {
|
||||||
|
if !response.emitted_files.is_empty() {
|
||||||
let mut codes = HashMap::new();
|
let mut codes = HashMap::new();
|
||||||
let mut maps = HashMap::new();
|
let mut maps = HashMap::new();
|
||||||
let check_js = config.get_check_js();
|
let check_js = config.get_check_js();
|
||||||
|
@ -843,6 +844,7 @@ impl Graph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graph.flush()?;
|
graph.flush()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(ResultInfo {
|
Ok(ResultInfo {
|
||||||
diagnostics: response.diagnostics,
|
diagnostics: response.diagnostics,
|
||||||
|
@ -1950,13 +1952,37 @@ pub mod tests {
|
||||||
.expect("should have checked");
|
.expect("should have checked");
|
||||||
assert!(result_info.maybe_ignored_options.is_none());
|
assert!(result_info.maybe_ignored_options.is_none());
|
||||||
assert_eq!(result_info.stats.0.len(), 12);
|
assert_eq!(result_info.stats.0.len(), 12);
|
||||||
println!("{}", result_info.diagnostics);
|
|
||||||
assert!(result_info.diagnostics.is_empty());
|
assert!(result_info.diagnostics.is_empty());
|
||||||
let h = handler.borrow();
|
let h = handler.borrow();
|
||||||
assert_eq!(h.cache_calls.len(), 2);
|
assert_eq!(h.cache_calls.len(), 2);
|
||||||
assert_eq!(h.tsbuildinfo_calls.len(), 1);
|
assert_eq!(h.tsbuildinfo_calls.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn fix_graph_check_emit_diagnostics() {
|
||||||
|
let specifier =
|
||||||
|
ModuleSpecifier::resolve_url_or_path("file:///tests/diag.ts")
|
||||||
|
.expect("could not resolve module");
|
||||||
|
let (graph, handler) = setup(specifier).await;
|
||||||
|
let result_info = graph
|
||||||
|
.check(CheckOptions {
|
||||||
|
debug: false,
|
||||||
|
emit: true,
|
||||||
|
lib: TypeLib::DenoWindow,
|
||||||
|
maybe_config_path: None,
|
||||||
|
reload: false,
|
||||||
|
})
|
||||||
|
.expect("should have checked");
|
||||||
|
assert!(result_info.maybe_ignored_options.is_none());
|
||||||
|
assert_eq!(result_info.stats.0.len(), 12);
|
||||||
|
assert!(!result_info.diagnostics.is_empty());
|
||||||
|
let h = handler.borrow();
|
||||||
|
// we shouldn't cache any files or write out tsbuildinfo if there are
|
||||||
|
// diagnostic errors
|
||||||
|
assert_eq!(h.cache_calls.len(), 0);
|
||||||
|
assert_eq!(h.tsbuildinfo_calls.len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_graph_check_no_emit() {
|
async fn test_graph_check_no_emit() {
|
||||||
let specifier =
|
let specifier =
|
||||||
|
|
1
cli/tests/module_graph/file_tests-c-mod.ts
Normal file
1
cli/tests/module_graph/file_tests-c-mod.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export const c = "c";
|
4
cli/tests/module_graph/file_tests-diag.ts
Normal file
4
cli/tests/module_graph/file_tests-diag.ts
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import * as c from "./c/mod.ts";
|
||||||
|
|
||||||
|
// deno-lint-ignore no-undef
|
||||||
|
consol.log(c);
|
Loading…
Add table
Reference in a new issue