From 10fbfcbc79eb50cb7669b4aaf67f957d97d8d93b Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Sat, 12 Sep 2020 19:53:57 +1000 Subject: refactor: improve tsc diagnostics (#7420) --- cli/tsc.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'cli/tsc.rs') diff --git a/cli/tsc.rs b/cli/tsc.rs index fa1c79589..98e73ae21 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -1,8 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use crate::colors; -use crate::diagnostics::Diagnostic; -use crate::diagnostics::DiagnosticItem; +use crate::diagnostics::Diagnostics; use crate::disk_cache::DiskCache; use crate::file_fetcher::SourceFile; use crate::file_fetcher::SourceFileFetcher; @@ -396,7 +395,7 @@ struct EmittedSource { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct BundleResponse { - diagnostics: Diagnostic, + diagnostics: Diagnostics, bundle_output: Option, stats: Option>, } @@ -404,7 +403,7 @@ struct BundleResponse { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct CompileResponse { - diagnostics: Diagnostic, + diagnostics: Diagnostics, emit_map: HashMap, build_info: Option, stats: Option>, @@ -425,14 +424,14 @@ struct TranspileTsOptions { #[serde(rename_all = "camelCase")] #[allow(unused)] struct RuntimeBundleResponse { - diagnostics: Vec, + diagnostics: Diagnostics, output: String, } #[derive(Deserialize)] #[serde(rename_all = "camelCase")] struct RuntimeCompileResponse { - diagnostics: Vec, + diagnostics: Diagnostics, emit_map: HashMap, } @@ -647,7 +646,7 @@ impl TsCompiler { let compile_response: CompileResponse = serde_json::from_str(&json_str)?; - if !compile_response.diagnostics.items.is_empty() { + if !compile_response.diagnostics.0.is_empty() { return Err(ErrBox::error(compile_response.diagnostics.to_string())); } @@ -769,7 +768,7 @@ impl TsCompiler { maybe_log_stats(bundle_response.stats); - if !bundle_response.diagnostics.items.is_empty() { + if !bundle_response.diagnostics.0.is_empty() { return Err(ErrBox::error(bundle_response.diagnostics.to_string())); } @@ -1287,7 +1286,7 @@ pub async fn runtime_compile( let response: RuntimeCompileResponse = serde_json::from_str(&json_str)?; - if response.diagnostics.is_empty() && sources.is_none() { + if response.diagnostics.0.is_empty() && sources.is_none() { compiler.cache_emitted_files(response.emit_map)?; } -- cgit v1.2.3