@@ -348,6 +348,7 @@ namespace ts {
348348 let diagnosticsProducingTypeChecker : TypeChecker ;
349349 let noDiagnosticsTypeChecker : TypeChecker ;
350350 let classifiableNames : Map < string > ;
351+ const programSizeLimitExceeded = - 1 ;
351352 let programSizeForNonTsFiles = 0 ;
352353
353354 let skipDefaultLib = options . noLib ;
@@ -444,6 +445,10 @@ namespace ts {
444445
445446 return program ;
446447
448+ function exceedProgramSizeLimit ( ) {
449+ return ! options . disableSizeLimit && programSizeForNonTsFiles === programSizeLimitExceeded ;
450+ }
451+
447452 function getCommonSourceDirectory ( ) {
448453 if ( typeof commonSourceDirectory === "undefined" ) {
449454 if ( options . rootDir && checkSourceFilesBelongToPath ( files , options . rootDir ) ) {
@@ -1033,7 +1038,7 @@ namespace ts {
10331038 diagnosticArgument = [ fileName , "'" + supportedExtensions . join ( "', '" ) + "'" ] ;
10341039 }
10351040 else if ( ! findSourceFile ( fileName , toPath ( fileName , currentDirectory , getCanonicalFileName ) , isDefaultLib , refFile , refPos , refEnd ) ) {
1036- if ( hasTypeScriptFileExtension ( fileName ) || options . disableSizeLimit || programSizeForNonTsFiles !== - 1 ) {
1041+ if ( hasTypeScriptFileExtension ( fileName ) || ! exceedProgramSizeLimit ( ) ) {
10371042 diagnostic = Diagnostics . File_0_not_found ;
10381043 diagnosticArgument = [ fileName ] ;
10391044 }
@@ -1047,13 +1052,13 @@ namespace ts {
10471052 const nonTsFile : SourceFile = options . allowNonTsExtensions && findSourceFile ( fileName , toPath ( fileName , currentDirectory , getCanonicalFileName ) , isDefaultLib , refFile , refPos , refEnd ) ;
10481053 if ( ! nonTsFile ) {
10491054 if ( options . allowNonTsExtensions ) {
1050- if ( options . disableSizeLimit || programSizeForNonTsFiles !== - 1 ) {
1055+ if ( ! exceedProgramSizeLimit ( ) ) {
10511056 diagnostic = Diagnostics . File_0_not_found ;
10521057 diagnosticArgument = [ fileName ] ;
10531058 }
10541059 }
10551060 else if ( ! forEach ( supportedExtensions , extension => findSourceFile ( fileName + extension , toPath ( fileName + extension , currentDirectory , getCanonicalFileName ) , isDefaultLib , refFile , refPos , refEnd ) ) ) {
1056- if ( options . disableSizeLimit || programSizeForNonTsFiles !== - 1 ) {
1061+ if ( ! exceedProgramSizeLimit ( ) ) {
10571062 diagnostic = Diagnostics . File_0_not_found ;
10581063 fileName += ".ts" ;
10591064 diagnosticArgument = [ fileName ] ;
@@ -1096,7 +1101,7 @@ namespace ts {
10961101 }
10971102
10981103 const isNonTsFile = ! hasTypeScriptFileExtension ( fileName ) ;
1099- if ( isNonTsFile && ! options . disableSizeLimit && programSizeForNonTsFiles === - 1 ) {
1104+ if ( isNonTsFile && exceedProgramSizeLimit ( ) ) {
11001105 return undefined ;
11011106 }
11021107
@@ -1125,7 +1130,7 @@ namespace ts {
11251130 rootLevelDirectory += directorySeparator ;
11261131 }
11271132 programDiagnostics . add ( createCompilerDiagnostic ( Diagnostics . Too_many_JavaScript_files_in_the_project_Consider_specifying_the_exclude_setting_in_project_configuration_to_limit_included_source_folders_The_likely_folder_to_exclude_is_0_To_disable_the_project_size_limit_set_the_disableSizeLimit_compiler_option_to_true , rootLevelDirectory ) ) ;
1128- programSizeForNonTsFiles = - 1 ;
1133+ programSizeForNonTsFiles = programSizeLimitExceeded ;
11291134 return undefined ;
11301135 }
11311136 }
0 commit comments