@@ -220,7 +220,7 @@ namespace ts {
220220
221221 interface BuildInfoCacheEntry {
222222 path : Path ;
223- buildInfo : BuildInfo | false | string ;
223+ buildInfo : BuildInfo | false ;
224224 modifiedTime : Date ;
225225 }
226226
@@ -956,7 +956,7 @@ namespace ts {
956956 reportDeclarationDiagnostics ,
957957 /*write*/ undefined ,
958958 /*reportSummary*/ undefined ,
959- ( name , text , writeByteOrderMark ) => outputFiles . push ( { name, text, writeByteOrderMark } ) ,
959+ ( name , text , writeByteOrderMark , _onError , _sourceFiles , data ) => outputFiles . push ( { name, text, writeByteOrderMark, buildInfo : data ?. buildInfo } ) ,
960960 cancellationToken ,
961961 /*emitOnlyDts*/ false ,
962962 customTransformers || state . host . getCustomTransformers ?.( project )
@@ -985,8 +985,8 @@ namespace ts {
985985 let newestDeclarationFileContentChangedTime : Date | undefined ;
986986 const emitterDiagnostics = createDiagnosticCollection ( ) ;
987987 const emittedOutputs = new Map < Path , string > ( ) ;
988- const buildInfo = state . buildInfoCache . get ( projectPath ) ;
989- outputFiles . forEach ( ( { name, text, writeByteOrderMark } ) => {
988+ const buildInfoEntry = state . buildInfoCache . get ( projectPath ) ;
989+ outputFiles . forEach ( ( { name, text, writeByteOrderMark, buildInfo } ) => {
990990 if ( resultFlags === BuildResultFlags . DeclarationOutputUnchanged && isDeclarationFileName ( name ) ) {
991991 // Check for unchanged .d.ts files
992992 if ( state . readFileWithCache ( name ) === text ) {
@@ -1001,9 +1001,9 @@ namespace ts {
10011001
10021002 const path = toPath ( state , name ) ;
10031003 emittedOutputs . set ( path , name ) ;
1004- if ( buildInfo ?. path === path ) {
1005- buildInfo . buildInfo = text ;
1006- buildInfo . modifiedTime = getCurrentTime ( state ) ;
1004+ if ( buildInfoEntry ?. path === path ) {
1005+ buildInfoEntry . buildInfo = buildInfo ! ;
1006+ buildInfoEntry . modifiedTime = getCurrentTime ( state ) ;
10071007 }
10081008 writeFile ( writeFileCallback ? { writeFile : writeFileCallback } : compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
10091009 } ) ;
@@ -1021,15 +1021,15 @@ namespace ts {
10211021 function emitBuildInfo ( writeFileCallback ?: WriteFileCallback , cancellationToken ?: CancellationToken ) : EmitResult {
10221022 Debug . assertIsDefined ( program ) ;
10231023 Debug . assert ( step === BuildStep . EmitBuildInfo ) ;
1024- const emitResult = program . emitBuildInfo ( ( name , data , writeByteOrderMark , onError , sourceFiles ) => {
1024+ const emitResult = program . emitBuildInfo ( ( name , text , writeByteOrderMark , onError , sourceFiles , data ) => {
10251025 const path = toPath ( state , name ) ;
10261026 const buildInfo = state . buildInfoCache . get ( projectPath ) ;
10271027 if ( buildInfo ?. path === path ) {
1028- buildInfo . buildInfo = data ;
1028+ buildInfo . buildInfo = data ! . buildInfo ! ;
10291029 buildInfo . modifiedTime = getCurrentTime ( state ) ;
10301030 }
1031- if ( writeFileCallback ) writeFileCallback ( name , data , writeByteOrderMark , onError , sourceFiles ) ;
1032- else state . compilerHost . writeFile ( name , data , writeByteOrderMark , onError , sourceFiles ) ;
1031+ if ( writeFileCallback ) writeFileCallback ( name , text , writeByteOrderMark , onError , sourceFiles , data ) ;
1032+ else state . compilerHost . writeFile ( name , text , writeByteOrderMark , onError , sourceFiles , data ) ;
10331033 } , cancellationToken ) ;
10341034 if ( emitResult . diagnostics . length ) {
10351035 reportErrors ( state , emitResult . diagnostics ) ;
@@ -1127,13 +1127,13 @@ namespace ts {
11271127 Debug . assert ( ! ! outputFiles . length ) ;
11281128 const emitterDiagnostics = createDiagnosticCollection ( ) ;
11291129 const emittedOutputs = new Map < Path , string > ( ) ;
1130- const buildInfo = state . buildInfoCache . get ( projectPath ) ;
1131- outputFiles . forEach ( ( { name, text, writeByteOrderMark } ) => {
1130+ const buildInfoEntry = state . buildInfoCache . get ( projectPath ) ;
1131+ outputFiles . forEach ( ( { name, text, writeByteOrderMark, buildInfo } ) => {
11321132 const path = toPath ( state , name ) ;
11331133 emittedOutputs . set ( path , name ) ;
1134- if ( buildInfo ?. path === path ) {
1135- buildInfo . buildInfo = text ;
1136- buildInfo . modifiedTime = getCurrentTime ( state ) ;
1134+ if ( buildInfoEntry ?. path === path ) {
1135+ buildInfoEntry . buildInfo = buildInfo ! ;
1136+ buildInfoEntry . modifiedTime = getCurrentTime ( state ) ;
11371137 }
11381138 writeFile ( writeFileCallback ? { writeFile : writeFileCallback } : compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
11391139 } ) ;
@@ -1433,9 +1433,7 @@ namespace ts {
14331433 const path = toPath ( state , buildInfoPath ) ;
14341434 const existing = state . buildInfoCache . get ( resolvedConfigPath ) ;
14351435 if ( existing !== undefined && existing . path === path ) {
1436- return isString ( existing . buildInfo ) ?
1437- existing . buildInfo = ts . getBuildInfo ( existing . buildInfo ) :
1438- existing . buildInfo || undefined ;
1436+ return existing . buildInfo || undefined ;
14391437 }
14401438 const value = state . readFileWithCache ( buildInfoPath ) ;
14411439 const buildInfo = value ? ts . getBuildInfo ( value ) : undefined ;
0 commit comments