@@ -713,8 +713,7 @@ namespace ts {
713
713
let files : SourceFile [ ] ;
714
714
let symlinks : ReadonlyMap < string > | undefined ;
715
715
let commonSourceDirectory : string ;
716
- let diagnosticsProducingTypeChecker : TypeChecker ;
717
- let noDiagnosticsTypeChecker : TypeChecker ;
716
+ let typeChecker : TypeChecker ;
718
717
let classifiableNames : UnderscoreEscapedMap < true > ;
719
718
const ambientModuleNameToUnmodifiedFileName = createMap < string > ( ) ;
720
719
// Todo:: Use this to report why file was included in --extendedDiagnostics
@@ -945,20 +944,18 @@ namespace ts {
945
944
getProgramDiagnostics,
946
945
getTypeChecker,
947
946
getClassifiableNames,
948
- getDiagnosticsProducingTypeChecker,
949
947
getCommonSourceDirectory,
950
948
emit,
951
949
getCurrentDirectory : ( ) => currentDirectory ,
952
- getNodeCount : ( ) => getDiagnosticsProducingTypeChecker ( ) . getNodeCount ( ) ,
953
- getIdentifierCount : ( ) => getDiagnosticsProducingTypeChecker ( ) . getIdentifierCount ( ) ,
954
- getSymbolCount : ( ) => getDiagnosticsProducingTypeChecker ( ) . getSymbolCount ( ) ,
955
- getTypeCount : ( ) => getDiagnosticsProducingTypeChecker ( ) . getTypeCount ( ) ,
956
- getRelationCacheSizes : ( ) => getDiagnosticsProducingTypeChecker ( ) . getRelationCacheSizes ( ) ,
950
+ getNodeCount : ( ) => getTypeChecker ( ) . getNodeCount ( ) ,
951
+ getIdentifierCount : ( ) => getTypeChecker ( ) . getIdentifierCount ( ) ,
952
+ getSymbolCount : ( ) => getTypeChecker ( ) . getSymbolCount ( ) ,
953
+ getTypeCount : ( ) => getTypeChecker ( ) . getTypeCount ( ) ,
954
+ getRelationCacheSizes : ( ) => getTypeChecker ( ) . getRelationCacheSizes ( ) ,
957
955
getFileProcessingDiagnostics : ( ) => fileProcessingDiagnostics ,
958
956
getResolvedTypeReferenceDirectives : ( ) => resolvedTypeReferenceDirectives ,
959
957
isSourceFileFromExternalLibrary,
960
958
isSourceFileDefaultLibrary,
961
- dropDiagnosticsProducingTypeChecker,
962
959
getSourceFileFromReference,
963
960
getLibFileFromReference,
964
961
sourceFileToPackageName,
@@ -1554,16 +1551,8 @@ namespace ts {
1554
1551
}
1555
1552
}
1556
1553
1557
- function getDiagnosticsProducingTypeChecker ( ) {
1558
- return diagnosticsProducingTypeChecker || ( diagnosticsProducingTypeChecker = createTypeChecker ( program , /*produceDiagnostics:*/ true ) ) ;
1559
- }
1560
-
1561
- function dropDiagnosticsProducingTypeChecker ( ) {
1562
- diagnosticsProducingTypeChecker = undefined ! ;
1563
- }
1564
-
1565
1554
function getTypeChecker ( ) {
1566
- return noDiagnosticsTypeChecker || ( noDiagnosticsTypeChecker = createTypeChecker ( program , /*produceDiagnostics:*/ false ) ) ;
1555
+ return typeChecker || ( typeChecker = createTypeChecker ( program ) ) ;
1567
1556
}
1568
1557
1569
1558
function emit ( sourceFile ?: SourceFile , writeFileCallback ?: WriteFileCallback , cancellationToken ?: CancellationToken , emitOnlyDtsFiles ?: boolean , transformers ?: CustomTransformers , forceDtsEmit ?: boolean ) : EmitResult {
@@ -1588,7 +1577,7 @@ namespace ts {
1588
1577
// This is because in the -out scenario all files need to be emitted, and therefore all
1589
1578
// files need to be type checked. And the way to specify that all files need to be type
1590
1579
// checked is to not pass the file to getEmitResolver.
1591
- const emitResolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( ( options . outFile || options . out ) ? undefined : sourceFile , cancellationToken ) ;
1580
+ const emitResolver = getTypeChecker ( ) . getEmitResolver ( ( options . outFile || options . out ) ? undefined : sourceFile , cancellationToken ) ;
1592
1581
1593
1582
performance . mark ( "beforeEmit" ) ;
1594
1583
@@ -1694,15 +1683,7 @@ namespace ts {
1694
1683
if ( e instanceof OperationCanceledException ) {
1695
1684
// We were canceled while performing the operation. Because our type checker
1696
1685
// might be a bad state, we need to throw it away.
1697
- //
1698
- // Note: we are overly aggressive here. We do not actually *have* to throw away
1699
- // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
1700
- // the lifetimes of these two TypeCheckers the same. Also, we generally only
1701
- // cancel when the user has made a change anyways. And, in that case, we (the
1702
- // program instance) will get thrown away anyways. So trying to keep one of
1703
- // these type checkers alive doesn't serve much purpose.
1704
- noDiagnosticsTypeChecker = undefined ! ;
1705
- diagnosticsProducingTypeChecker = undefined ! ;
1686
+ typeChecker = undefined ! ;
1706
1687
}
1707
1688
1708
1689
throw e ;
@@ -1726,7 +1707,7 @@ namespace ts {
1726
1707
return emptyArray ;
1727
1708
}
1728
1709
1729
- const typeChecker = getDiagnosticsProducingTypeChecker ( ) ;
1710
+ const typeChecker = getTypeChecker ( ) ;
1730
1711
1731
1712
Debug . assert ( ! ! sourceFile . bindDiagnostics ) ;
1732
1713
@@ -1754,7 +1735,7 @@ namespace ts {
1754
1735
1755
1736
function getSuggestionDiagnostics ( sourceFile : SourceFile , cancellationToken : CancellationToken ) : readonly DiagnosticWithLocation [ ] {
1756
1737
return runWithCancellationToken ( ( ) => {
1757
- return getDiagnosticsProducingTypeChecker ( ) . getSuggestionDiagnostics ( sourceFile , cancellationToken ) ;
1738
+ return getTypeChecker ( ) . getSuggestionDiagnostics ( sourceFile , cancellationToken ) ;
1758
1739
} ) ;
1759
1740
}
1760
1741
@@ -1991,7 +1972,7 @@ namespace ts {
1991
1972
1992
1973
function getDeclarationDiagnosticsForFileNoCache ( sourceFile : SourceFile | undefined , cancellationToken : CancellationToken | undefined ) : readonly DiagnosticWithLocation [ ] {
1993
1974
return runWithCancellationToken ( ( ) => {
1994
- const resolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( sourceFile , cancellationToken ) ;
1975
+ const resolver = getTypeChecker ( ) . getEmitResolver ( sourceFile , cancellationToken ) ;
1995
1976
// Don't actually write any files since we're just getting diagnostics.
1996
1977
return ts . getDeclarationDiagnostics ( getEmitHost ( noop ) , resolver , sourceFile ) || emptyArray ;
1997
1978
} ) ;
@@ -2050,7 +2031,7 @@ namespace ts {
2050
2031
}
2051
2032
2052
2033
function getGlobalDiagnostics ( ) : SortedReadonlyArray < Diagnostic > {
2053
- return rootNames . length ? sortAndDeduplicateDiagnostics ( getDiagnosticsProducingTypeChecker ( ) . getGlobalDiagnostics ( ) . slice ( ) ) : emptyArray as any as SortedReadonlyArray < Diagnostic > ;
2034
+ return rootNames . length ? sortAndDeduplicateDiagnostics ( getTypeChecker ( ) . getGlobalDiagnostics ( ) . slice ( ) ) : emptyArray as any as SortedReadonlyArray < Diagnostic > ;
2054
2035
}
2055
2036
2056
2037
function getConfigFileParsingDiagnostics ( ) : readonly Diagnostic [ ] {
0 commit comments