Search Terms
diagnosticsProducingTypeChecker
TypeChecker
getTypeChecker
Suggestion
Expose getDiagnosticsProducingTypeChecker.
Use Cases
A custom compiler adding additional checks must currently call:
// program: typescript.Program
const originalDiagnostics = program.get*Diagnostics(sourceFile);
const typeChecker: typescript.TypeChecker = program.getTypeChecker();
/* Use `typeChecker` to check the source file for additional diagnostics. */
Internally, get*Diagnostics methods use getDiagnosticsProducingTypeChecker, so it is already "warmed" - types are already instantiated. The current implementation requires that a compiler pay the cost to instantiate types twice: once with a diagnosticsProducingTypeChecker, and once with a noDiagnosticsTypeChecker.
This would eliminate the redundant warm-up cost for instantiating types in the TypeChecker. This would be especially effective in code bases with deeply nested type definitions which may take noticeably longer to instantiate.
I do not fully understand the difference between the two TypeCheckers, so I cannot honestly comment on the drawbacks to exposing/using a diagnosticsProducingTypeChecker for custom checks (can someone please explain this, or point me towards documentation?). If it is unfeasible, perhaps there is a way to warm both checkers on the same run, to reduce the repeated type instantiations.
Examples
See Use Cases.
Checklist
My suggestion meets these guidelines:
Search Terms
diagnosticsProducingTypeChecker
TypeChecker
getTypeChecker
Suggestion
Expose
getDiagnosticsProducingTypeChecker.Use Cases
A custom compiler adding additional checks must currently call:
Internally,
get*Diagnosticsmethods usegetDiagnosticsProducingTypeChecker, so it is already "warmed" - types are already instantiated. The current implementation requires that a compiler pay the cost to instantiate types twice: once with adiagnosticsProducingTypeChecker, and once with anoDiagnosticsTypeChecker.This would eliminate the redundant warm-up cost for instantiating types in the
TypeChecker. This would be especially effective in code bases with deeply nested type definitions which may take noticeably longer to instantiate.I do not fully understand the difference between the two
TypeCheckers, so I cannot honestly comment on the drawbacks to exposing/using adiagnosticsProducingTypeCheckerfor custom checks (can someone please explain this, or point me towards documentation?). If it is unfeasible, perhaps there is a way to warm both checkers on the same run, to reduce the repeated type instantiations.Examples
See Use Cases.
Checklist
My suggestion meets these guidelines: