Skip to content

Report JSON syntax errors from extended tsconfig files#4141

Open
Copilot wants to merge 15 commits into
mainfrom
copilot/fix-tsgo-json-errors
Open

Report JSON syntax errors from extended tsconfig files#4141
Copilot wants to merge 15 commits into
mainfrom
copilot/fix-tsgo-json-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

tsgo silently ignored JSON syntax errors in config files referenced via extends, so invalid base configs produced no diagnostics. The parser now surfaces those diagnostics from the extended config file.

  • Extended config parsing

    • Propagate JSON parser diagnostics when an extended config is read successfully but cannot be parsed.
    • Preserve existing missing-file behavior without duplicating read errors.
  • Regression coverage

    • Added coverage for an invalid bad.json referenced by tsconfig.json.
    • Verifies expected parse tokens and diagnostic attribution to the extended file.
{
  "extends": "./bad.json"
}
{ this is not json

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI and others added 10 commits May 31, 2026 12:27
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
Copilot AI requested a review from jakebailey May 31, 2026 12:40
Comment thread internal/tsoptions/tsconfigparsing.go Outdated
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()...)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot This code is really hard to reason about. I think it can be rephrased to make the flow clearer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>
Copilot AI requested a review from jakebailey June 1, 2026 17:43
@jakebailey jakebailey marked this pull request as ready for review June 1, 2026 19:15
Copilot AI review requested due to automatic review settings June 1, 2026 19:15
Copy link
Copy Markdown
Contributor

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 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.

@jakebailey
Copy link
Copy Markdown
Member

@copilot merge main

…-errors

# Conflicts:
#	internal/tsoptions/tsconfigparsing_test.go

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 2, 2026

@copilot merge main

Merged origin/main in 5d9bf02 and resolved the tsconfig parsing test conflict while preserving both tests. Validation passed with go test ./internal/tsoptions, npm run build, and final PR validation.

Copilot AI requested a review from jakebailey June 2, 2026 22:47
@jakebailey jakebailey requested a review from RyanCavanaugh June 3, 2026 03:10
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 7.0 RC milestone Jun 3, 2026
@RyanCavanaugh RyanCavanaugh requested a review from iisaduan June 3, 2026 17:43
@jakebailey
Copy link
Copy Markdown
Member

@copilot merge main

…-errors

# Conflicts:
#	internal/tsoptions/tsconfigparsing_test.go

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 4, 2026

@copilot merge main

Merged origin/main in 90310f4 and resolved the tsconfig parsing test conflict while preserving both tests. Validation passed with go test ./internal/tsoptions and npm run build.

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.

tsgo silently swallows JSON syntax errors in an extended tsconfig.json file

5 participants