Skip to content
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

Reuse type reference resolutions between programs when possible #48388

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

weswigham
Copy link
Member

Fixes a perf issue I noticed while looking at #48278 - we were always unconditionally redoing type reference resolution, even when we had old ones we could reuse.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Mar 23, 2022
@@ -3074,6 +3074,28 @@ namespace ts {
return;
}

const existingResolutions = file.resolvedTypeReferenceDirectiveNames;
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to add method that does something similar to `` instead of calling resolveTypeReferenceDirectiveNamesWorker where the resolutions are reused and call it from `tryReuseStructureFromOldProgram` as well

This change currently has two points lacking:

  1. it doesnt handle case where source files are modified and program tries to compute new module resolutions and type reference directives. (look in tryReuseStructureFromOldProgram)
  2. Doesnt report error esolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext when reusing

Copy link
Member Author

Choose a reason for hiding this comment

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

it doesnt handle case where source files are modified and program tries to compute new module resolutions and type reference directives.

tryReuseStructureFromOldProgram already overwrites resolvedTypeReferenceDirectiveNames with new resolutions when they change (and sets StructureIsReused.SafeModules rather than StructureIsReused.Completely - not that it matters here, since we have a full new resolved resolution list already made in the former case, so don't need to redo what tryReuseStructureFromOldProgram's already calculated) - we just didn't use the result here.

Doesnt report error esolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext when reusing

Done.

Copy link
Member

Choose a reason for hiding this comment

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

@weswigham weswigham marked this pull request as draft August 13, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

3 participants