From 62ff3b5d32426a6bab4f6558c4f2b59556710f60 Mon Sep 17 00:00:00 2001 From: Thomas Broyer Date: Tue, 16 Jan 2024 11:34:38 +0100 Subject: [PATCH] Allow expectError diagnostic codes to ignore to override syntactical errors There are a few diagnostic codes that are < 2000 but aren't really syntactical errors. They can thus be listed in expectErrorDiagnosticCodesToIgnore to be "expected" by expecteError. --- source/lib/compiler.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/lib/compiler.ts b/source/lib/compiler.ts index 1697084..8330362 100644 --- a/source/lib/compiler.ts +++ b/source/lib/compiler.ts @@ -76,6 +76,10 @@ const ignoreDiagnostic = ( // Diagnostic is inside of `expectError` clause if (diagnosticFileName === location.fileName && start > location.start && start < location.end) { + if (expectErrorDiagnosticCodesToIgnore.has(diagnostic.code)) { + return location; + } + // Ignore syntactical errors if (diagnostic.code < 2000) { expectedErrors.delete(location); @@ -83,12 +87,8 @@ const ignoreDiagnostic = ( } // Set diagnostic code on `ExpectedError` to log - if (!expectErrorDiagnosticCodesToIgnore.has(diagnostic.code)) { - error.code = diagnostic.code; - return 'preserve'; - } - - return location; + error.code = diagnostic.code; + return 'preserve'; } }