fix(tsoptions): validate project reference fields#4494
Open
TorinAsakura wants to merge 4 commits into
Open
Conversation
jakebailey
reviewed
Jun 30, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens tsconfig project reference parsing in internal/tsoptions by validating references[].path and references[].circular before constructing core.ProjectReference entries, converting previously panicking/silent-failure scenarios into config diagnostics (Fixes #4269).
Changes:
- Added typed/empty-string validation for
references[].pathand type validation forreferences[].circular, emitting appropriate diagnostics instead of panicking or omitting references. - Introduced a helper to attach diagnostics to the most relevant
references[]property node when parsing from a JSONSourceFile. - Added unit tests covering invalid project reference fields for both source-file parsing and object-based config parsing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/tsoptions/tsconfigparsing.go | Validates references entries, emits targeted diagnostics, and adds a helper for precise diagnostic locations. |
| internal/tsoptions/tsconfigparsing_test.go | Adds test coverage for invalid references[].path / references[].circular across both config parsing entry points. |
| internal/tsoptions/parsinghelpers.go | Makes project reference parsing type-safe by returning a structured parse result instead of using unsafe type assertions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4269.
Before
A project reference with a non-string path could panic while parsing the config:
A project reference with an empty path was silently omitted from the build graph:
After
Invalid project reference fields are reported as config diagnostics instead of panicking; the repro includes the referenced config so this only shows the project-reference field diagnostics:
An empty project reference path is now diagnosed instead of silently ignored:
Validation