@@ -542,6 +542,49 @@ namespace ts.tscWatch {
542542 ] ,
543543 expectedIncrementalErrors : file2Errors ,
544544 } ) ;
545+
546+ it ( "verify that state is read correctly" , ( ) => {
547+ const system = createWatchedSystem ( [ libFile , file1 , fileModified , config ] , { currentDirectory : project } ) ;
548+ incrementalBuild ( "tsconfig.json" , system ) ;
549+
550+ const command = parseConfigFileWithSystem ( "tsconfig.json" , { } , system , noop ) ! ;
551+ const builderProgram = createIncrementalProgram ( {
552+ rootNames : command . fileNames ,
553+ options : command . options ,
554+ projectReferences : command . projectReferences ,
555+ configFileParsingDiagnostics : getConfigFileParsingDiagnostics ( command ) ,
556+ host : createIncrementalCompilerHost ( command . options , system )
557+ } ) ;
558+
559+ const state = builderProgram . getState ( ) ;
560+ assert . equal ( state . changedFilesSet ! . size , 0 , "changes" ) ;
561+
562+ assert . equal ( state . fileInfos . size , 3 , "FileInfo size" ) ;
563+ assert . deepEqual ( state . fileInfos . get ( libFile . path ) , libFileInfo ) ;
564+ assert . deepEqual ( state . fileInfos . get ( file1 . path ) , getFileInfo ( file1 . content ) ) ;
565+ assert . deepEqual ( state . fileInfos . get ( file2 . path ) , file2FileInfo ) ;
566+
567+ assert . deepEqual ( state . compilerOptions , {
568+ incremental : true ,
569+ module : ModuleKind . AMD ,
570+ configFilePath : config . path
571+ } ) ;
572+
573+ assert . equal ( state . referencedMap ! . size , 0 ) ;
574+ assert . equal ( state . exportedModulesMap ! . size , 0 ) ;
575+
576+ assert . equal ( state . semanticDiagnosticsPerFile ! . size , 3 ) ;
577+ assert . deepEqual ( state . semanticDiagnosticsPerFile ! . get ( libFile . path ) , emptyArray ) ;
578+ assert . deepEqual ( state . semanticDiagnosticsPerFile ! . get ( file1 . path ) , emptyArray ) ;
579+ const { file : _ , relatedInformation : __ , ...rest } = file2ReuasableError [ 1 ] [ 0 ] ;
580+ assert . deepEqual ( state . semanticDiagnosticsPerFile ! . get ( file2 . path ) , [ {
581+ ...rest ,
582+ file : state . program ! . getSourceFileByPath ( file2 . path as Path ) ! ,
583+ relatedInformation : undefined ,
584+ reportsUnnecessary : undefined ,
585+ source : undefined
586+ } ] ) ;
587+ } ) ;
545588 } ) ;
546589
547590 describe ( "with --out" , ( ) => {
0 commit comments