Skip to content

Conversation

gabritto
Copy link
Member

In Corsa, GetProgramDiagnostics was including all diagnostics of the includeProcessor, which includes /// <reference ...> diagnostics and resolution diagnostics. Because we did that, an error e.g. in a bad /// <reference type="non-existent"/> in a lib file would be included in the output of a command line execution even if the project had skipLibCheck: true.

This PR changes this so that GetProgramDiagnostics now only includes global includeProcessor diagnostics.
This is basically what Strada did (see program.getCombinedDiagnostics there).
The file-specific includeProcessor diagnostics are now obtained via getSemanticDiagnosticsForFile. This is also what Strada did.
The result is that in getSemanticDiagnosticsForFile, we have a chance to check if that file should be skipped per skipLibCheck, and we'll also handle // @ts-ignore correctly as well for these diagnostics.

@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 23:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR changes how processing diagnostics (like /// <reference ...> directives) are handled to match the behavior of Strada (the TypeScript compiler). Instead of including all processing diagnostics in GetProgramDiagnostics, it now only includes global processing diagnostics, while file-specific processing diagnostics are handled through getSemanticDiagnosticsForFile. This ensures that skipLibCheck: true properly filters out processing diagnostics from library files.

Key Changes:

  • Modified GetProgramDiagnostics to only include global processing diagnostics
  • Updated getSemanticDiagnosticsForFile to include file-specific processing diagnostics
  • Added a test case to verify that processing diagnostics in library files are properly skipped when skipLibCheck: true

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

File Description
testdata/tests/cases/compiler/processingDiagnosticSkipLibCheck.ts New test case demonstrating that processing diagnostics in library files should be skipped when skipLibCheck: true
internal/compiler/program.go Modified diagnostic collection to separate global and file-specific processing diagnostics
testdata/baselines/reference/* Updated baselines showing improved diagnostic behavior with file-specific error reporting
internal/execute/tsctests/tscbuild_test.go Updated test comment reflecting corrected behavior

"../../animals/dog.ts",
"../../animals/index.ts",
"../../core/utilities.ts"
[
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could tell, these new errors are correct and show up in the Strada baselines for these tests.

return SortAndDeduplicateDiagnostics(slices.Concat(p.programDiagnostics, p.includeProcessor.getDiagnostics(p).GetDiagnostics()))
return SortAndDeduplicateDiagnostics(slices.Concat(
p.programDiagnostics,
p.includeProcessor.getDiagnostics(p).GetGlobalDiagnostics()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
p.includeProcessor.getDiagnostics(p).GetGlobalDiagnostics()))
p.includeProcessor.getDiagnostics(p).GetGlobalDiagnostics(),
))

Nit (sorry)

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, feel free to not do the formatting nit 😄

@gabritto gabritto added this pull request to the merge queue Aug 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 25, 2025
@gabritto gabritto added this pull request to the merge queue Aug 25, 2025
Merged via the queue into main with commit 7376eb2 Aug 25, 2025
22 checks passed
@gabritto gabritto deleted the gabritto/processordiagnostics branch August 25, 2025 15:42
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants