0
0
Fork 0
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:
Kitson Kelly 2020-11-09 21:21:49 +11:00 committed by GitHub
parent 71d7482577
commit 293cae5e1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 39 deletions

View file

@ -800,7 +800,8 @@ impl Graph {
graph.maybe_tsbuildinfo = response.maybe_tsbuildinfo;
// Only process changes to the graph if there are no diagnostics and there
// 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 maps = HashMap::new();
let check_js = config.get_check_js();
@ -843,6 +844,7 @@ impl Graph {
}
}
graph.flush()?;
}
Ok(ResultInfo {
diagnostics: response.diagnostics,
@ -1950,13 +1952,37 @@ pub mod tests {
.expect("should have checked");
assert!(result_info.maybe_ignored_options.is_none());
assert_eq!(result_info.stats.0.len(), 12);
println!("{}", result_info.diagnostics);
assert!(result_info.diagnostics.is_empty());
let h = handler.borrow();
assert_eq!(h.cache_calls.len(), 2);
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]
async fn test_graph_check_no_emit() {
let specifier =

View file

@ -0,0 +1 @@
export const c = "c";

View file

@ -0,0 +1,4 @@
import * as c from "./c/mod.ts";
// deno-lint-ignore no-undef
consol.log(c);