-
Notifications
You must be signed in to change notification settings - Fork 653
Fix extended tsconfig paths #1268
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
Conversation
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>
Do not create new unit tests files. Only add tests to |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Done. Removed the separate test files and moved all test cases to |
This fails the tests, you did not accept the baselines and then add them to the PR. |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Fixed. Baselines have been accepted using |
Fix the formatting by running |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Fixed formatting using |
The docs say:
So, this can't be the right fix. Surely there's a test or to in |
… merge Previously, typescript-go was incorrectly merging arrays from extended and extending configs. TypeScript actually uses overwrite behavior: if the inheriting config has files/include/exclude arrays, they completely replace the base config's arrays. This change implements the correct behavior as per TypeScript documentation: "files, include, and exclude from the inheriting config file overwrite those from the base config file" - If inheriting config has the property: use only inheriting config's value - If inheriting config lacks the property: inherit from extended config - Updated tests to verify correct overwrite behavior - All tests now pass including the original issue #1267 scenario Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
You're absolutely right. I was incorrectly merging the arrays when TypeScript actually uses overwrite behavior. Fixed to match TypeScript's documented behavior: "files, include, and exclude from the inheriting config file overwrite those from the base config file". Now uses overwrite logic instead of merge - if the inheriting config has the property, it completely ignores the extended config's property. 1c5f941 |
You are done, the bug is fixed. Please update the PR description to accurately reflect what happened in the PR. |
Updated the PR description to accurately reflect the fix. The issue was in the relativeDifference calculation for extended tsconfig path resolution, not array merging behavior. 701060d |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
...nfig/tsconfigParsing/extends with files overwrite - both configs have files with json api.js
Outdated
Show resolved
Hide resolved
…ested Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Just wanted to call out that I just rebuilt tsg based on this branch and tested with my codebase (the one used on the original issue) and everything works as expected! |
Problem
When using
tsg
(TypeScript Go), files specified in thefiles
array of an extended tsconfig were not being properly picked up. This caused type declaration files from base configs to be missing during compilation, leading to type errors that didn't occur with the standard TypeScript compiler.Consider this monorepo setup:
Base tsconfig (
@motion/tsconfig-backend/backend.json
):Package tsconfig:
With
tsc
, both the type declaration files from the base config AND the source files from the include pattern would be processed. However, withtsg
, only the source files were being included - the type declarations were ignored.Root Cause
The issue was in the
relativeDifference
calculation in thesetPropertyValue
function intsconfigparsing.go
. When processing files from extended configs, the code was incorrectly computing the relative path used to resolve file paths from the extended config.The problematic code was:
This meant that files from extended configs were being resolved relative to the wrong directory, causing them to not be found.
Solution
Fixed the
relativeDifference
calculation to match TypeScript's behavior inapplyExtendedConfig
. The correct calculation uses:This ensures that files from extended configs are resolved relative to the extended config's directory, not the current working directory or the extending config's directory.
Testing
Added comprehensive test cases that verify:
All existing tests continue to pass, ensuring no regressions.
Fixes #1267.