Open
Conversation
The matchesSpecs function used the config file directory as the base path for pattern matching, causing include patterns to correctly match source files and filter them out. TypeScript's convertToTSConfig uses the config file path (including the filename) as the base, which causes include patterns to never match source files, so all resolved files appear in the files output. Changed Go code to match TypeScript's behavior. Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/6094e405-8017-4e5c-aa1d-5faafce1f785 Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix --showConfig to include files field in output
Fix Apr 5, 2026
--showConfig to include files field
jakebailey
reviewed
Apr 5, 2026
internal/tsoptions/showconfig.go
Outdated
| // (including the filename, e.g. "/project/tsconfig.json") is used as the base path | ||
| // for pattern matching, not the directory. This causes include patterns like "**/*" | ||
| // to resolve relative to the file (e.g. "/project/tsconfig.json/**/*"), which never | ||
| // matches actual source files, so all resolved files appear in the "files" output. |
Member
There was a problem hiding this comment.
@copilot Rather than port the buggy code to maintain this behavior, just implement it from scratch in a way that makes it obvious that we are just sticking everything in here.
Contributor
Author
There was a problem hiding this comment.
Simplified in b66ec50 — removed matchesSpecs entirely and just include all resolved files directly. No more porting the buggy filter logic.
Instead of porting TypeScript's buggy matchesSpecs behavior (where using the config file path as base causes patterns to never match), simply include all resolved files in the output directly. Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/219fac50-44be-4142-ad1c-7c5eed695897 Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes tsgo --showConfig so it includes the files field (listing resolved root files) in cases where tsc --showConfig does, aligning tsgo output with TypeScript’s behavior.
Changes:
- Removed include/exclude-based filtering when constructing the
fileslist;--showConfignow emits all resolved files. - Added a regression test covering
outDir+excludewith no explicitfiles/include. - Updated/added showConfig baselines to reflect the newly-present
filesfield.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/tsoptions/showconfig.go | Always emits files as all resolved root files (relative paths), removing prior filtering logic and dependency on vfsmatch. |
| internal/execute/tsctests/showconfig_test.go | Adds a new --showConfig test scenario for exclude + outDir. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-transitively-implied-options.js | Baseline updated to include files. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-references.js | Baseline updated to include files. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-paths-and-more.js | Baseline updated to include files. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-include-filtering-files.js | Baseline updated to include files. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-files-and-include.js | Baseline updated to include files (now includes resolved included files too). |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-exclude.js | Baseline updated to include files. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-exclude-and-outDir.js | New baseline for the added regression test scenario. |
| testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-compileOnSave-and-more.js | Baseline updated to include files. |
Comments suppressed due to low confidence (1)
internal/tsoptions/showconfig.go:77
- Minor perf:
filesgrows via append without a capacity hint. SinceconfigParseResult.FileNames()is already available, consider preallocatingfileswithmake([]string, 0, len(...))to avoid repeated reallocations for large projects.
var files []string
for _, f := range configParseResult.FileNames() {
normalizedFilePath := tspath.GetNormalizedAbsolutePath(f, configParseResult.GetCurrentDirectory())
relativePath := tspath.GetRelativePathFromFile(normalizedConfigPath, normalizedFilePath, comparePathsOptions)
files = append(files, relativePath)
}
When no tsconfig is loaded (e.g., `tsgo --showConfig file0.ts`),
configFileName is empty. GetNormalizedAbsolutePath("", cwd) returns
just the cwd, and GetRelativePathFromFile treats it as a file path,
relativizing from its parent directory — producing incorrect paths
like ./project/file0.ts.
Default to "tsconfig.json" so relativization works correctly from
the current directory.
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/54494f3a-f6b4-4dd4-9f3d-37adcfd6a231
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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.
tsgo --showConfigomits thefilesfield from output whiletsc --showConfigincludes all resolved files.Root cause:
matchesSpecsinshowconfig.goused the config file's directory as the base path for glob matching, causing include patterns like**/*to correctly match source files and filter them all out. TypeScript'sconvertToTSConfighas a bug where it passes the config file path (includingtsconfig.jsonfilename) togetFileMatcherPatterns, producing patterns that never match actual source files—so all resolved files pass through to the output.Fix:
matchesSpecsfunction entirely rather than porting TypeScript's buggy filtering logicvfsmatchimport (no longer needed)configFileNamecase (e.g.,tsgo --showConfig file0.tswith no tsconfig loaded) by defaulting to"tsconfig.json", so path relativization works correctly from the current directory instead of its parentoutDir+exclude, no explicitfiles/include)filesfield