Skip to content

Implement tryLoadInputFileForPath, file loader diags #1302

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

Merged
merged 18 commits into from
Jul 3, 2025
Merged

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jun 27, 2025

Fixes #1079
Fixes #1345

@Copilot Copilot AI review requested due to automatic review settings June 27, 2025 03:37
Copy link
Contributor

@Copilot Copilot AI left a 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 implements the tryLoadInputFileForPath function to map output file paths back to input files for package self-names when outDir or declarationDir are used, addressing #1079. It also updates several baseline files to reflect the expected output changes and introduces new helper functions to compute common source directories and candidate output directories.

Reviewed Changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated 1 comment.

File Description
testdata/baselines/reference/** Baseline files for conformance, types, symbols, and errors have been updated to align with the self-name resolution changes.
internal/module/resolver.go The tryLoadInputFileForPath function and several related helper methods have been added/modified to support output-to-input path mapping.
Comments suppressed due to low confidence (1)

internal/module/resolver.go:773

  • [nitpick] Given the multiple branching paths and the intricate logic for guessing the common source directory, additional compiler tests to cover edge cases for these calculations would help ensure stability as the project evolves.
		var commonSourceDirGuesses []string

@jakebailey jakebailey marked this pull request as draft June 27, 2025 03:46
@jakebailey jakebailey marked this pull request as ready for review June 27, 2025 04:11
@jakebailey jakebailey requested a review from andrewbranch June 27, 2025 04:15
@jakebailey jakebailey mentioned this pull request Jul 2, 2025
@jakebailey jakebailey changed the title Implement tryLoadInputFileForPath Implement tryLoadInputFileForPath, add program diags Jul 2, 2025
@jakebailey jakebailey changed the title Implement tryLoadInputFileForPath, add program diags Implement tryLoadInputFileForPath, file loader diags Jul 2, 2025
@jakebailey
Copy link
Member Author

jakebailey commented Jul 2, 2025

I've removed the guessing logic, erroring if we don't have RootDir or ConfigFilePath. This still works to fix the two linked issues.

@jakebailey jakebailey requested a review from andrewbranch July 2, 2025 21:32
@jakebailey jakebailey enabled auto-merge July 2, 2025 21:46
if r.compilerOptions.RootDir != "" {
// A `rootDir` compiler option strongly indicates the root location
rootDir = r.compilerOptions.RootDir
} else if r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to microsoft/TypeScript#54500, the --composite check will go away in 6.0, making the error below only possible for non-tsconfig builds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I do that now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just going to let this merge and address it separately if needed, given this will unbreak people

@jakebailey jakebailey added this pull request to the merge queue Jul 3, 2025
@jakebailey jakebailey removed this pull request from the merge queue due to a manual request Jul 3, 2025
@jakebailey jakebailey added this pull request to the merge queue Jul 3, 2025
Merged via the queue into main with commit 104aea5 Jul 3, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/fix-1079 branch July 3, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subpath imports referencing compiled JS files not resolved Erroring on first compilation, subsequent compilation is successful
2 participants