Skip to content

Commit

Permalink
Allow expectError diagnostic codes to ignore to override syntactical …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
tbroyer committed Jan 16, 2024
1 parent bb28db1 commit 62ff3b5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ 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);
return 'preserve';
}

// 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';
}
}

Expand Down

0 comments on commit 62ff3b5

Please sign in to comment.