@@ -440,7 +440,7 @@ namespace ts {
440
440
createBuilderStatusReporter ( sys , shouldBePretty ( sys , buildOptions ) ) ,
441
441
createWatchStatusReporter ( sys , buildOptions )
442
442
) ;
443
- updateSolutionBuilderHost ( sys , cb , buildHost ) ;
443
+ updateSolutionBuilderHost ( sys , reportDiagnostic , cb , buildHost ) ;
444
444
const builder = createSolutionBuilderWithWatch ( buildHost , projects , buildOptions , watchOptions ) ;
445
445
builder . build ( ) ;
446
446
return builder ;
@@ -453,7 +453,7 @@ namespace ts {
453
453
createBuilderStatusReporter ( sys , shouldBePretty ( sys , buildOptions ) ) ,
454
454
createReportErrorSummary ( sys , buildOptions )
455
455
) ;
456
- updateSolutionBuilderHost ( sys , cb , buildHost ) ;
456
+ updateSolutionBuilderHost ( sys , reportDiagnostic , cb , buildHost ) ;
457
457
const builder = createSolutionBuilder ( buildHost , projects , buildOptions ) ;
458
458
const exitStatus = buildOptions . clean ? builder . clean ( ) : builder . build ( ) ;
459
459
return sys . exit ( exitStatus ) ;
@@ -492,7 +492,7 @@ namespace ts {
492
492
s => sys . write ( s + sys . newLine ) ,
493
493
createReportErrorSummary ( sys , options )
494
494
) ;
495
- reportStatistics ( sys , program ) ;
495
+ reportStatistics ( sys , program , reportDiagnostic ) ;
496
496
cb ( program ) ;
497
497
return sys . exit ( exitStatus ) ;
498
498
}
@@ -516,7 +516,7 @@ namespace ts {
516
516
reportDiagnostic,
517
517
reportErrorSummary : createReportErrorSummary ( sys , options ) ,
518
518
afterProgramEmitAndDiagnostics : builderProgram => {
519
- reportStatistics ( sys , builderProgram . getProgram ( ) ) ;
519
+ reportStatistics ( sys , builderProgram . getProgram ( ) , reportDiagnostic ) ;
520
520
cb ( builderProgram ) ;
521
521
}
522
522
} ) ;
@@ -525,12 +525,13 @@ namespace ts {
525
525
526
526
function updateSolutionBuilderHost (
527
527
sys : System ,
528
+ reportDiagnostic : DiagnosticReporter ,
528
529
cb : ExecuteCommandLineCallbacks ,
529
530
buildHost : SolutionBuilderHostBase < EmitAndSemanticDiagnosticsBuilderProgram >
530
531
) {
531
532
updateCreateProgram ( sys , buildHost ) ;
532
533
buildHost . afterProgramEmitAndDiagnostics = program => {
533
- reportStatistics ( sys , program . getProgram ( ) ) ;
534
+ reportStatistics ( sys , program . getProgram ( ) , reportDiagnostic ) ;
534
535
cb ( program ) ;
535
536
} ;
536
537
buildHost . afterEmitBundle = cb ;
@@ -549,14 +550,15 @@ namespace ts {
549
550
550
551
function updateWatchCompilationHost (
551
552
sys : System ,
553
+ reportDiagnostic : DiagnosticReporter ,
552
554
cb : ExecuteCommandLineCallbacks ,
553
555
watchCompilerHost : WatchCompilerHost < EmitAndSemanticDiagnosticsBuilderProgram > ,
554
556
) {
555
557
updateCreateProgram ( sys , watchCompilerHost ) ;
556
558
const emitFilesUsingBuilder = watchCompilerHost . afterProgramCreate ! ; // TODO: GH#18217
557
559
watchCompilerHost . afterProgramCreate = builderProgram => {
558
560
emitFilesUsingBuilder ( builderProgram ) ;
559
- reportStatistics ( sys , builderProgram . getProgram ( ) ) ;
561
+ reportStatistics ( sys , builderProgram . getProgram ( ) , reportDiagnostic ) ;
560
562
cb ( builderProgram ) ;
561
563
} ;
562
564
}
@@ -581,7 +583,7 @@ namespace ts {
581
583
reportDiagnostic,
582
584
reportWatchStatus : createWatchStatusReporter ( system , configParseResult . options )
583
585
} ) ;
584
- updateWatchCompilationHost ( system , cb , watchCompilerHost ) ;
586
+ updateWatchCompilationHost ( system , reportDiagnostic , cb , watchCompilerHost ) ;
585
587
watchCompilerHost . configFileParsingResult = configParseResult ;
586
588
return createWatchProgram ( watchCompilerHost ) ;
587
589
}
@@ -602,7 +604,7 @@ namespace ts {
602
604
reportDiagnostic,
603
605
reportWatchStatus : createWatchStatusReporter ( system , options )
604
606
} ) ;
605
- updateWatchCompilationHost ( system , cb , watchCompilerHost ) ;
607
+ updateWatchCompilationHost ( system , reportDiagnostic , cb , watchCompilerHost ) ;
606
608
return createWatchProgram ( watchCompilerHost ) ;
607
609
}
608
610
@@ -616,9 +618,21 @@ namespace ts {
616
618
}
617
619
}
618
620
619
- function reportStatistics ( sys : System , program : Program ) {
621
+ function reportStatistics ( sys : System , program : Program , reportDiagnostic : DiagnosticReporter ) {
620
622
let statistics : Statistic [ ] ;
621
623
const compilerOptions = program . getCompilerOptions ( ) ;
624
+
625
+ if ( compilerOptions . expensiveStatements ) {
626
+ for ( const expensiveStatement of program . getExpensiveStatements ( ) ) {
627
+ reportDiagnostic (
628
+ createDiagnosticForNode (
629
+ expensiveStatement . node ,
630
+ Diagnostics . Checking_this_statement_may_result_in_the_creation_of_as_many_as_0_types_and_1_symbols ,
631
+ expensiveStatement . typeDelta ,
632
+ expensiveStatement . symbolDelta ) ) ;
633
+ }
634
+ }
635
+
622
636
if ( canReportDiagnostics ( sys , compilerOptions ) ) {
623
637
statistics = [ ] ;
624
638
const memoryUsed = sys . getMemoryUsage ? sys . getMemoryUsage ( ) : - 1 ;
0 commit comments