Port tryLoadInputFileForPath from TypeScript codebase#1346
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR ports the TypeScript tryLoadInputFileForPath logic into our Go resolver, adds two helpers for mapping output files back to source inputs, and updates a slew of compiler tests and baselines to reflect the new “self-name + outDir” behavior.
- Implement
tryLoadInputFileForPathsupport for package self-names withoutDir/declarationDir, guessing common source directories and mapping outputs back to inputs - Add helpers
getPossibleOriginalInputExtensionForExtensionandgetOutputDirectoriesForBaseDirectory - Introduce a new test (
subpathImportJS.ts) and update many baseline files undertestdata/baselinesto match the new resolution behavior
Reviewed Changes
Copilot reviewed 61 out of 61 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/module/resolver.go | Ported tryLoadInputFileForPath logic from TS; added helpers for extension and directory guesses |
| testdata/tests/cases/compiler/subpathImportJS.ts | New test exercising package import maps and self-paths |
| testdata/baselines/reference/... | Updated expected outputs/errors/symbols/types to match new resolution results |
|
This is pending in #1302 |
|
Yeah, I don't think we need this PR, given #1302 is the same? Just, a discussion about if we are keeping this logic or if there's some better thing we can do? |
|
Going to close this for clarity, but if you see something in my PR that your PR did better, absolutely tell me. |
|
I trust that you have a clear idea what you want to achieve - I merely told Copilot to port the TypeScript implementation as close as possible. |
|
I have to admit, I also did that (which succeeded). |
Fixes: #1345
and improves several baselines of existing tests
I don't fully grasp some of the error diffs, but the other changes at least look like an improvement to me.
Disclaimer: I burned a couple of tokens to get Claude to port this, since I don't understand enough of the codebase to make this change on my own - so please check that no nonsense slipped in.