@@ -79,6 +79,7 @@ namespace ts {
7979 UpstreamOutOfDate ,
8080 UpstreamBlocked ,
8181 ComputingUpstream ,
82+ TsVersionOutputOfDate ,
8283
8384 /**
8485 * Projects with no outputs (i.e. "solution" files)
@@ -96,6 +97,7 @@ namespace ts {
9697 | Status . UpstreamOutOfDate
9798 | Status . UpstreamBlocked
9899 | Status . ComputingUpstream
100+ | Status . TsVersionOutOfDate
99101 | Status . ContainerOnly ;
100102
101103 export namespace Status {
@@ -181,6 +183,11 @@ namespace ts {
181183 type : UpToDateStatusType . ComputingUpstream ;
182184 }
183185
186+ export interface TsVersionOutOfDate {
187+ type : UpToDateStatusType . TsVersionOutputOfDate ;
188+ version : string ;
189+ }
190+
184191 /**
185192 * One or more of the project's outputs is older than the newest output of
186193 * an upstream project.
@@ -454,6 +461,8 @@ namespace ts {
454461 return result ;
455462 } ;
456463
464+ const buildInfoChecked = createFileMap < true > ( toPath ) ;
465+
457466 // Watch state
458467 const builderPrograms = createFileMap < T > ( toPath ) ;
459468 const diagnostics = createFileMap < ReadonlyArray < Diagnostic > > ( toPath ) ;
@@ -499,6 +508,7 @@ namespace ts {
499508 projectStatus . clear ( ) ;
500509 missingRoots . clear ( ) ;
501510 globalDependencyGraph = undefined ;
511+ buildInfoChecked . clear ( ) ;
502512
503513 diagnostics . clear ( ) ;
504514 projectPendingBuild . clear ( ) ;
@@ -844,6 +854,21 @@ namespace ts {
844854 } ;
845855 }
846856
857+ if ( ! buildInfoChecked . hasKey ( project . options . configFilePath as ResolvedConfigFileName ) ) {
858+ buildInfoChecked . setValue ( project . options . configFilePath as ResolvedConfigFileName , true ) ;
859+ const buildInfoPath = getOutputPathForBuildInfo ( project . options ) ;
860+ if ( buildInfoPath ) {
861+ const value = readFileWithCache ( buildInfoPath ) ;
862+ const buildInfo = value && getBuildInfo ( value ) ;
863+ if ( buildInfo && buildInfo . version !== version ) {
864+ return {
865+ type : UpToDateStatusType . TsVersionOutputOfDate ,
866+ version : buildInfo . version
867+ } ;
868+ }
869+ }
870+ }
871+
847872 if ( usesPrepend && pseudoUpToDate ) {
848873 return {
849874 type : UpToDateStatusType . OutOfDateWithPrepend ,
@@ -1220,7 +1245,8 @@ namespace ts {
12201245 if ( ! buildInfoPath ) return undefined ;
12211246 const content = readFileWithCache ( buildInfoPath ) ;
12221247 if ( ! content ) return undefined ;
1223- const buildInfo = JSON . parse ( content ) as BuildInfo ;
1248+ const buildInfo = getBuildInfo ( content ) ;
1249+ if ( buildInfo . version !== version ) return undefined ;
12241250 return buildInfo . program && createBuildProgramUsingProgramBuildInfo ( buildInfo . program ) as any as T ;
12251251 }
12261252
@@ -1545,6 +1571,11 @@ namespace ts {
15451571 return formatMessage ( Diagnostics . Failed_to_parse_file_0_Colon_1 ,
15461572 relName ( configFileName ) ,
15471573 status . reason ) ;
1574+ case UpToDateStatusType . TsVersionOutputOfDate :
1575+ return formatMessage ( Diagnostics . Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2 ,
1576+ relName ( configFileName ) ,
1577+ status . version ,
1578+ version ) ;
15481579 case UpToDateStatusType . ContainerOnly :
15491580 // Don't report status on "solution" projects
15501581 case UpToDateStatusType . ComputingUpstream :
0 commit comments