Skip to content

Commit b424f36

Browse files
authored
Expose call count for instantiateType in extendedDiagnostics (microsoft#36797)
* Expose call count for instantiateType in extendedDiagnostics * Update API baselines
1 parent 3d63401 commit b424f36

6 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ namespace ts {
298298
let typeCount = 0;
299299
let symbolCount = 0;
300300
let enumCount = 0;
301+
let totalInstantiationCount = 0;
301302
let instantiationCount = 0;
302303
let instantiationDepth = 0;
303304
let constraintDepth = 0;
@@ -348,6 +349,7 @@ namespace ts {
348349
getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"),
349350
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount,
350351
getTypeCount: () => typeCount,
352+
getInstantiationCount: () => totalInstantiationCount,
351353
getRelationCacheSizes: () => ({
352354
assignable: assignableRelation.size,
353355
identity: identityRelation.size,
@@ -13775,6 +13777,7 @@ namespace ts {
1377513777
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
1377613778
return errorType;
1377713779
}
13780+
totalInstantiationCount++;
1377813781
instantiationCount++;
1377913782
instantiationDepth++;
1378013783
const result = instantiateTypeWorker(type, mapper);

src/compiler/program.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@ namespace ts {
946946
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
947947
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
948948
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
949+
getInstantiationCount: () => getDiagnosticsProducingTypeChecker().getInstantiationCount(),
949950
getRelationCacheSizes: () => getDiagnosticsProducingTypeChecker().getRelationCacheSizes(),
950951
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
951952
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,

src/compiler/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,7 @@ namespace ts {
32353235
getIdentifierCount(): number;
32363236
getSymbolCount(): number;
32373237
getTypeCount(): number;
3238+
getInstantiationCount(): number;
32383239
getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number };
32393240

32403241
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
@@ -3557,6 +3558,7 @@ namespace ts {
35573558
/* @internal */ getIdentifierCount(): number;
35583559
/* @internal */ getSymbolCount(): number;
35593560
/* @internal */ getTypeCount(): number;
3561+
/* @internal */ getInstantiationCount(): number;
35603562
/* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number };
35613563

35623564
/* @internal */ isArrayType(type: Type): boolean;

src/executeCommandLine/executeCommandLine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ namespace ts {
639639
reportCountStatistic("Identifiers", program.getIdentifierCount());
640640
reportCountStatistic("Symbols", program.getSymbolCount());
641641
reportCountStatistic("Types", program.getTypeCount());
642+
reportCountStatistic("Instantiations", program.getInstantiationCount());
642643

643644
if (memoryUsed >= 0) {
644645
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,7 @@ declare namespace ts {
19521952
getIdentifierCount(): number;
19531953
getSymbolCount(): number;
19541954
getTypeCount(): number;
1955+
getInstantiationCount(): number;
19551956
getRelationCacheSizes(): {
19561957
assignable: number;
19571958
identity: number;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,7 @@ declare namespace ts {
19521952
getIdentifierCount(): number;
19531953
getSymbolCount(): number;
19541954
getTypeCount(): number;
1955+
getInstantiationCount(): number;
19551956
getRelationCacheSizes(): {
19561957
assignable: number;
19571958
identity: number;

0 commit comments

Comments
 (0)