Report JSON syntax errors from extended tsconfig files#4141
Open
Copilot wants to merge 15 commits into
Open
Conversation
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Syashanurshahana
approved these changes
May 31, 2026
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with tsgo not reporting JSON syntax errors
Report JSON syntax errors from extended tsconfig files
May 31, 2026
jakebailey
reviewed
Jun 1, 2026
Comment on lines
1008
to
1016
| extendedResult, readErrors := readJsonConfigFile(fileName, path, host.FS().ReadFile) | ||
| entryErrors = append(entryErrors, readErrors...) | ||
| if len(extendedResult.SourceFile.Diagnostics()) == 0 { | ||
| extendedConfig, err = parseConfig(nil, extendedResult, host, tspath.GetDirectoryPath(fileName), tspath.GetBaseFileName(fileName), resolutionStack, extendedConfigCache) | ||
| entryErrors = append(entryErrors, err...) | ||
| var parseErrors []*ast.Diagnostic | ||
| extendedConfig, parseErrors = parseConfig(nil, extendedResult, host, tspath.GetDirectoryPath(fileName), tspath.GetBaseFileName(fileName), resolutionStack, extendedConfigCache) | ||
| entryErrors = append(entryErrors, parseErrors...) | ||
| } else if len(readErrors) == 0 { | ||
| entryErrors = append(entryErrors, extendedResult.SourceFile.Diagnostics()...) | ||
| } |
Member
There was a problem hiding this comment.
@copilot This code is really hard to reason about. I think it can be rephrased to make the flow clearer.
Contributor
Author
There was a problem hiding this comment.
Addressed in f98d1ef by splitting the extended-config handling into explicit read-error, JSON-parse-error, and successful-parse paths.
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
jakebailey
approved these changes
Jun 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a diagnostics gap in tsgo’s tsconfig parsing: JSON syntax errors in config files referenced via extends were previously not surfaced, leading to silent failures when base configs were invalid.
Changes:
- Propagate JSON parser diagnostics from extended config files (
extends) when the file is readable but fails JSON parsing. - Preserve existing “cannot read file” behavior without duplicating read errors.
- Add a regression test that asserts the reported diagnostics are attributed to the extended config file.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/tsoptions/tsconfigparsing.go | Returns JSON parse diagnostics from extended configs (and continues to short-circuit on read errors). |
| internal/tsoptions/tsconfigparsing_test.go | Adds regression coverage ensuring invalid extended JSON produces expected-token diagnostics attributed to the extended file. |
RyanCavanaugh
approved these changes
Jun 2, 2026
Member
|
@copilot merge main |
…-errors # Conflicts: # internal/tsoptions/tsconfigparsing_test.go Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Contributor
Author
Member
|
@copilot merge main |
…-errors # Conflicts: # internal/tsoptions/tsconfigparsing_test.go Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Contributor
Author
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.
tsgosilently ignored JSON syntax errors in config files referenced viaextends, so invalid base configs produced no diagnostics. The parser now surfaces those diagnostics from the extended config file.Extended config parsing
Regression coverage
bad.jsonreferenced bytsconfig.json.{ "extends": "./bad.json" }{ this is not json