-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
base: main
Are you sure you want to change the base?
Reuse type reference resolutions between programs when possible #48388
Conversation
@@ -3074,6 +3074,28 @@ namespace ts { | |||
return; | |||
} | |||
|
|||
const existingResolutions = file.resolvedTypeReferenceDirectiveNames; |
There was a problem hiding this comment.
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:
- it doesnt handle case where source files are modified and program tries to compute new module resolutions and type reference directives. (look in
tryReuseStructureFromOldProgram
) - Doesnt report error
esolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext
when reusing
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StructureIsReused.SafeModules
can be set even without computing new type reference directive resolutions (https://github.com/microsoft/TypeScript/blob/main/src/compiler/program.ts#L1799) Thats why you need something like https://github.com/microsoft/TypeScript/blob/main/src/compiler/program.ts#L1483 and https://github.com/microsoft/TypeScript/blob/main/src/compiler/program.ts#L1525
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.