Skip to content

[api] Report project reference diagnostics on programs without a config file - #64637

Open
Christopher Plieger (cplieger) wants to merge 1 commit into
microsoft:mainfrom
cplieger:fix-api-nil-configfile-project-reference
Open

Christopher Plieger (cplieger) wants to merge 1 commit into
microsoft:mainfrom
cplieger:fix-api-nil-configfile-project-reference

Conversation

@cplieger

@cplieger Christopher Plieger (cplieger) commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
  • There is an associated issue in the Backlog milestone (required)
  • Code is up-to-date with the main branch
  • You've successfully run npx hereby test
  • You've successfully run npx hereby lint
  • You've successfully run npx hereby check:format
  • There are new or updated tests validating the change

Fixes #64629

A program created through createPrograms has no configuration file, so its ParsedCommandLine.ConfigFile is nil. Any project reference diagnostic on such a program crashes the API server with a nil pointer dereference in CreateDiagnosticAtReferenceSyntax.

Impact: a tool that builds its own program for a repository that references a non-composite project kills the whole API server process, losing every open snapshot, and the tool sees only an EOF. That is an ordinary monorepo setup, where tsc -p reports TS6306 and keeps going, so an analyzer on the API stops on that repository instead of analyzing it.

CreateDiagnosticAtReferenceSyntax now returns nil when ConfigFile is nil, and its caller in verifyProjectReferences already falls back to a compiler diagnostic in that case.

TestCreateProgramReportsNonCompositeProjectReference creates such a program with a reference to a non-composite project and expects TS6306 as its only program diagnostic, and it panics without the fix.

I met this while building deadset-ts, the TypeScript analyzer of deadset, on the TypeScript 7 API. That work hit a small set of related defects, which is why a few reports come from me.

An AI coding agent wrote this patch. I have read, built and tested it and will handle the review.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 10:28
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused fix correctly uses the existing compiler-diagnostic fallback and includes regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents API crashes when synthetic programs without config files report project-reference diagnostics.

Changes:

  • Adds a nil guard before accessing ConfigFile.
  • Adds regression coverage for TS6306 reporting.
File Description
tsc/​internal/​tsoptions/​tsconfigparsing.go Falls back when reference syntax is unavailable.
tsc/​internal/​api/​session_createprogram_test.go Verifies non-composite reference diagnostics.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

[api] createPrograms with a non-composite projectReferences entry crashes the API server

2 participants