@@ -1033,8 +1033,10 @@ namespace ts {
10331033 diagnosticArgument = [ fileName , "'" + supportedExtensions . join ( "', '" ) + "'" ] ;
10341034 }
10351035 else if ( ! findSourceFile ( fileName , toPath ( fileName , currentDirectory , getCanonicalFileName ) , isDefaultLib , refFile , refPos , refEnd ) ) {
1036- diagnostic = Diagnostics . File_0_not_found ;
1037- diagnosticArgument = [ fileName ] ;
1036+ if ( hasTypeScriptFileExtension ( fileName ) || options . disableSizeLimit || programSizeForNonTsFiles !== - 1 ) {
1037+ diagnostic = Diagnostics . File_0_not_found ;
1038+ diagnosticArgument = [ fileName ] ;
1039+ }
10381040 }
10391041 else if ( refFile && host . getCanonicalFileName ( fileName ) === host . getCanonicalFileName ( refFile . fileName ) ) {
10401042 diagnostic = Diagnostics . A_file_cannot_have_a_reference_to_itself ;
@@ -1045,13 +1047,17 @@ namespace ts {
10451047 const nonTsFile : SourceFile = options . allowNonTsExtensions && findSourceFile ( fileName , toPath ( fileName , currentDirectory , getCanonicalFileName ) , isDefaultLib , refFile , refPos , refEnd ) ;
10461048 if ( ! nonTsFile ) {
10471049 if ( options . allowNonTsExtensions ) {
1048- diagnostic = Diagnostics . File_0_not_found ;
1049- diagnosticArgument = [ fileName ] ;
1050+ if ( options . disableSizeLimit || programSizeForNonTsFiles !== - 1 ) {
1051+ diagnostic = Diagnostics . File_0_not_found ;
1052+ diagnosticArgument = [ fileName ] ;
1053+ }
10501054 }
10511055 else if ( ! forEach ( supportedExtensions , extension => findSourceFile ( fileName + extension , toPath ( fileName + extension , currentDirectory , getCanonicalFileName ) , isDefaultLib , refFile , refPos , refEnd ) ) ) {
1052- diagnostic = Diagnostics . File_0_not_found ;
1053- fileName += ".ts" ;
1054- diagnosticArgument = [ fileName ] ;
1056+ if ( options . disableSizeLimit || programSizeForNonTsFiles !== - 1 ) {
1057+ diagnostic = Diagnostics . File_0_not_found ;
1058+ fileName += ".ts" ;
1059+ diagnosticArgument = [ fileName ] ;
1060+ }
10551061 }
10561062 }
10571063 }
@@ -1089,7 +1095,8 @@ namespace ts {
10891095 return file ;
10901096 }
10911097
1092- if ( ! options . disableSizeLimit && programSizeForNonTsFiles === - 1 ) {
1098+ const isNonTsFile = ! hasTypeScriptFileExtension ( fileName ) ;
1099+ if ( isNonTsFile && ! options . disableSizeLimit && programSizeForNonTsFiles === - 1 ) {
10931100 return undefined ;
10941101 }
10951102
@@ -1104,7 +1111,7 @@ namespace ts {
11041111 }
11051112 } ) ;
11061113
1107- if ( ! options . disableSizeLimit && file && file . text && ! hasTypeScriptFileExtension ( file . fileName ) ) {
1114+ if ( isNonTsFile && ! options . disableSizeLimit && file && file . text ) {
11081115 programSizeForNonTsFiles += file . text . length ;
11091116 if ( programSizeForNonTsFiles > maxProgramSizeForNonTsFiles ) {
11101117 // If the program size limit was reached when processing a file, this file is
0 commit comments