-
Notifications
You must be signed in to change notification settings - Fork 703
Fix out of bounds panic when tsconfig "files" contains duplicates #1675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix out of bounds panic when tsconfig "files" contains duplicates #1675
Conversation
Wait this isn't quite right |
Yes it is. Test modification proves it |
There was a problem hiding this 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 an out-of-bounds panic when the tsconfig "files" array contains duplicate entries. The solution tracks the actual number of literal files separately from the total file count, preventing incorrect array slicing when duplicates cause the literal file count to be smaller than expected.
Key changes:
- Modified
getFileNamesFromConfigSpecs
to return both file names and literal file count - Added
literalFileNamesLen
field to track the actual number of unique literal files - Updated
LiteralFileNames()
method to use the tracked count instead of the original file spec length
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
internal/tsoptions/tsconfigparsing.go | Modified file name resolution functions to return literal file count and updated parsing logic to track this count |
internal/tsoptions/parsedcommandline.go | Added literalFileNamesLen field and updated LiteralFileNames() method to use the tracked count instead of file spec length |
internal/tsoptions/parsedcommandline_test.go | Added test case to verify duplicate files in tsconfig are handled correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is a duplicate; I wasn’t targeting a fix to programs at all. The test case added here, using only config file parsing and its methods, panics without the fix. |
Oh i see.. I forgot that we use Literal file names stuff for watching and matching.. |
Discovered this while investigating something else