summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-03-31 16:39:40 -0400
committerGitHub <noreply@github.com>2024-03-31 16:39:40 -0400
commitb8af46e0075f659f4e373e249b0f19b3cb0f62a9 (patch)
tree9a029e81b6d7d4294b729dc5db860b015368b1ba /cli/tsc
parent01445940449cedc571dcbd69caa7da58de007f2b (diff)
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
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/diagnostics.rs13
1 files changed, 10 insertions, 3 deletions
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<P>(&self, predicate: P) -> Self
+ pub fn filter<P>(self, predicate: P) -> Self
where
- P: FnMut(&Diagnostic) -> Option<Diagnostic>,
+ P: FnMut(&Diagnostic) -> bool,
{
- let diagnostics = self.0.iter().filter_map(predicate).collect();
+ let diagnostics = self.0.into_iter().filter(predicate).collect();
Self(diagnostics)
}