fix: getDefaultLibFilePath should normalize __dirname
#49051
Merged
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.
Summary
Fixes a bug (#49050) where
getDefaultLibFilePathreturns mixed path separators on WindowsDetails
this currently causes a bug on Windows with mixed path separators
__dirname, and then adds a forward slash from thedirectorySeparator, causing mixed separators/internally and lets the host convert if needed, so I assume this should be normalized to all forward slashses insteadevery other use of
__dirnamein the codebase seems to be normalized except for this onenormalizeSlashesfor this, but I figurecombinePathsis more appropriate since that will handle it and combine properly as well without any+ directorySeparator +stuffTesting
All existing tests pass, but I couldn't find an existing unit test for
getDefaultLibFilePath, and theAPISampletests are meant to be 1-to-1 with the Wiki, so I didn't think that was the right place for them either.It seemed like nearly all of the tests were integration tests and did not directly test single files or functions such as this one, at least as far as I could tell -- please let me know if that's incorrect! I did find a
unittestsdir, but there was only one file in it, so not sure if that's the right place for a test for this either.The
CONTRIBUTING.mdseems to only cover adding fixtures/integration tests (not sure what the "proper" word for it is in this codebase since testing terminology is a bit team-dependent I find), and not a unit test of a function like this.Please direct me as to where it would be best to add a test for this!
References
Fixes #49050
Also fixes downstream ezolenko/rollup-plugin-typescript2#321 (comment)