Fix tsconfig/jsconfig priority for JS files when both configs coexist in same directory#3740
Merged
Merged
Conversation
… when searching for ancestor of tsconfig.json When both tsconfig.json and jsconfig.json exist in the same directory, JS files should be managed by jsconfig.json when tsconfig.json doesn't include them (e.g., allowJs is false). Previously, computeConfigFileName would skip the entire directory when searching for ancestor configs. Now, matching TSServer's behavior, when searching for the ancestor of a tsconfig.json, we only skip tsconfig.json itself and still check for jsconfig.json in the same directory. Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/8525f366-6fcd-472b-8124-ef393ba8263b Co-authored-by: sandersn <293473+sandersn@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix tsconfig.json priority over jsconfig.json in same directory
Fix tsconfig/jsconfig priority for JS files when both configs coexist in same directory
May 7, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes configured-project discovery so that when tsconfig.json and jsconfig.json coexist in the same directory, JavaScript files can still be correctly picked up by jsconfig.json (instead of falling through to the inferred project) after tsconfig.json is found but does not include the JS file.
Changes:
- Adjusted
computeConfigFileNameancestor search to skiptsconfig.jsonbut still consider a siblingjsconfig.jsonwhen the starting file istsconfig.json. - Added a session test asserting JS files route to the
jsconfig.jsonproject while TS files route to thetsconfig.jsonproject when both configs exist.
Show a summary per file
| File | Description |
|---|---|
| internal/project/configfileregistrybuilder.go | Refines per-config skipping behavior during ancestor config discovery to match TSServer behavior in mixed tsconfig/jsconfig directories. |
| internal/project/session_test.go | Adds regression test for JS-vs-TS default project selection when both configs exist side-by-side. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
andrewbranch
approved these changes
May 7, 2026
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.
When
tsconfig.jsonandjsconfig.jsoncoexist in the same directory, JS files were always falling through to the inferred project instead of being picked up byjsconfig.json. The ancestor config search incomputeConfigFileNamewas skipping the entire starting directory, preventing discovery of a siblingjsconfig.jsonaftertsconfig.jsonrejected the file.Fix
Aligned
computeConfigFileNamewith TSServer'sforEachConfigFileLocationbehavior:tsconfig.json: skiptsconfig.jsonbut still checkjsconfig.jsonin the same directoryjsconfig.json: skip both (unchanged behavior)Test
Added test verifying JS files route to
jsconfig.jsonand TS files route totsconfig.jsonwhen both configs exist in the same directory.