From b8af46e0075f659f4e373e249b0f19b3cb0f62a9 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 31 Mar 2024 16:39:40 -0400 Subject: fix(check): ignore certain diagnostics in remote modules and when publishing (#23119) Unused locals and parameters don't make sense to surface in remote modules. Additionally, fast check can cause these kind of diagnostics when publishing, so they should be ignored. Closes #22959 --- cli/tsc/diagnostics.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cli/tsc') diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs index 362385c07..9525d1855 100644 --- a/cli/tsc/diagnostics.rs +++ b/cli/tsc/diagnostics.rs @@ -136,6 +136,13 @@ pub struct Diagnostic { } impl Diagnostic { + /// If this diagnostic should be included when it comes from a remote module. + pub fn include_when_remote(&self) -> bool { + /// TS6133: value is declared but its value is never read (noUnusedParameters and noUnusedLocals) + const TS6133: u64 = 6133; + self.code != TS6133 + } + fn fmt_category_and_code(&self, f: &mut fmt::Formatter) -> fmt::Result { let category = match self.category { DiagnosticCategory::Error => "ERROR", @@ -275,11 +282,11 @@ impl Diagnostics { /// Return a set of diagnostics where only the values where the predicate /// returns `true` are included. - pub fn filter

(&self, predicate: P) -> Self + pub fn filter

(self, predicate: P) -> Self where - P: FnMut(&Diagnostic) -> Option, + P: FnMut(&Diagnostic) -> bool, { - let diagnostics = self.0.iter().filter_map(predicate).collect(); + let diagnostics = self.0.into_iter().filter(predicate).collect(); Self(diagnostics) } -- cgit v1.2.3