Correctly set filesByName map when reusing program to ensure it is same as old program #35784
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.
Previously we were setting these with each new sourceFile's
path
andresolvedPath
but that's not enough.Eg. if its monorepo like setup and we are using sourceOfProjectReferenceRedirect with preserveSymlinks, we would get resolvedFileName of the moduleResolution as
node_modules/projectName/someFile.d.ts
and when creating new program without reusing old program, we would find that this is actually link to saysrc/someFile.ts
in referenced project and use that source file. So in that program we have entries forprojectName/src/someFile.ts
,projectName/lib/someFile.d.ts
as well asnode_modules/projectName/someFile.d.ts
all pointing tosomeFile.ts
sourceFile.In new program that uses old program previously we would only set
projectName/src/someFile.ts
,projectName/lib/someFile.d.ts
to point to the sourceFile ofsomeFile.ts
and hence in checker we would incorrectly think that module resolution has failed and report the error.Fixes #35768