@@ -220,7 +220,7 @@ namespace ts {
220
220
221
221
interface BuildInfoCacheEntry {
222
222
path : Path ;
223
- buildInfo : BuildInfo | false | string ;
223
+ buildInfo : BuildInfo | false ;
224
224
modifiedTime : Date ;
225
225
}
226
226
@@ -956,7 +956,7 @@ namespace ts {
956
956
reportDeclarationDiagnostics ,
957
957
/*write*/ undefined ,
958
958
/*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 } ) ,
960
960
cancellationToken ,
961
961
/*emitOnlyDts*/ false ,
962
962
customTransformers || state . host . getCustomTransformers ?.( project )
@@ -985,8 +985,8 @@ namespace ts {
985
985
let newestDeclarationFileContentChangedTime : Date | undefined ;
986
986
const emitterDiagnostics = createDiagnosticCollection ( ) ;
987
987
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 } ) => {
990
990
if ( resultFlags === BuildResultFlags . DeclarationOutputUnchanged && isDeclarationFileName ( name ) ) {
991
991
// Check for unchanged .d.ts files
992
992
if ( state . readFileWithCache ( name ) === text ) {
@@ -1001,9 +1001,9 @@ namespace ts {
1001
1001
1002
1002
const path = toPath ( state , name ) ;
1003
1003
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 ) ;
1007
1007
}
1008
1008
writeFile ( writeFileCallback ? { writeFile : writeFileCallback } : compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
1009
1009
} ) ;
@@ -1021,15 +1021,15 @@ namespace ts {
1021
1021
function emitBuildInfo ( writeFileCallback ?: WriteFileCallback , cancellationToken ?: CancellationToken ) : EmitResult {
1022
1022
Debug . assertIsDefined ( program ) ;
1023
1023
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 ) => {
1025
1025
const path = toPath ( state , name ) ;
1026
1026
const buildInfo = state . buildInfoCache . get ( projectPath ) ;
1027
1027
if ( buildInfo ?. path === path ) {
1028
- buildInfo . buildInfo = data ;
1028
+ buildInfo . buildInfo = data ! . buildInfo ! ;
1029
1029
buildInfo . modifiedTime = getCurrentTime ( state ) ;
1030
1030
}
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 ) ;
1033
1033
} , cancellationToken ) ;
1034
1034
if ( emitResult . diagnostics . length ) {
1035
1035
reportErrors ( state , emitResult . diagnostics ) ;
@@ -1127,13 +1127,13 @@ namespace ts {
1127
1127
Debug . assert ( ! ! outputFiles . length ) ;
1128
1128
const emitterDiagnostics = createDiagnosticCollection ( ) ;
1129
1129
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 } ) => {
1132
1132
const path = toPath ( state , name ) ;
1133
1133
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 ) ;
1137
1137
}
1138
1138
writeFile ( writeFileCallback ? { writeFile : writeFileCallback } : compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
1139
1139
} ) ;
@@ -1433,9 +1433,7 @@ namespace ts {
1433
1433
const path = toPath ( state , buildInfoPath ) ;
1434
1434
const existing = state . buildInfoCache . get ( resolvedConfigPath ) ;
1435
1435
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 ;
1439
1437
}
1440
1438
const value = state . readFileWithCache ( buildInfoPath ) ;
1441
1439
const buildInfo = value ? ts . getBuildInfo ( value ) : undefined ;
0 commit comments