@@ -21,10 +21,14 @@ namespace ts {
21
21
dry ?: boolean ;
22
22
force ?: boolean ;
23
23
verbose ?: boolean ;
24
+
24
25
/*@internal */ clean ?: boolean ;
25
26
/*@internal */ watch ?: boolean ;
26
27
/*@internal */ help ?: boolean ;
28
+
27
29
preserveWatchOutput ?: boolean ;
30
+ listEmittedFiles ?: boolean ;
31
+ listFiles ?: boolean ;
28
32
}
29
33
30
34
enum BuildResultFlags {
@@ -44,8 +48,9 @@ namespace ts {
44
48
SyntaxErrors = 1 << 3 ,
45
49
TypeErrors = 1 << 4 ,
46
50
DeclarationEmitErrors = 1 << 5 ,
51
+ EmitErrors = 1 << 6 ,
47
52
48
- AnyErrors = ConfigFileErrors | SyntaxErrors | TypeErrors | DeclarationEmitErrors
53
+ AnyErrors = ConfigFileErrors | SyntaxErrors | TypeErrors | DeclarationEmitErrors | EmitErrors
49
54
}
50
55
51
56
export enum UpToDateStatusType {
@@ -401,6 +406,7 @@ namespace ts {
401
406
const projectStatus = createFileMap < UpToDateStatus > ( toPath ) ;
402
407
const missingRoots = createMap < true > ( ) ;
403
408
let globalDependencyGraph : DependencyGraph | undefined ;
409
+ const writeFileName = ( s : string ) => host . trace && host . trace ( s ) ;
404
410
405
411
// Watch state
406
412
const diagnostics = createFileMap < ReadonlyArray < Diagnostic > > ( toPath ) ;
@@ -1014,35 +1020,28 @@ namespace ts {
1014
1020
...program . getConfigFileParsingDiagnostics ( ) ,
1015
1021
...program . getSyntacticDiagnostics ( ) ] ;
1016
1022
if ( syntaxDiagnostics . length ) {
1017
- resultFlags |= BuildResultFlags . SyntaxErrors ;
1018
- reportAndStoreErrors ( proj , syntaxDiagnostics ) ;
1019
- projectStatus . setValue ( proj , { type : UpToDateStatusType . Unbuildable , reason : "Syntactic errors" } ) ;
1020
- return resultFlags ;
1023
+ return buildErrors ( syntaxDiagnostics , BuildResultFlags . SyntaxErrors , "Syntactic" ) ;
1021
1024
}
1022
1025
1023
1026
// Don't emit .d.ts if there are decl file errors
1024
1027
if ( getEmitDeclarations ( program . getCompilerOptions ( ) ) ) {
1025
1028
const declDiagnostics = program . getDeclarationDiagnostics ( ) ;
1026
1029
if ( declDiagnostics . length ) {
1027
- resultFlags |= BuildResultFlags . DeclarationEmitErrors ;
1028
- reportAndStoreErrors ( proj , declDiagnostics ) ;
1029
- projectStatus . setValue ( proj , { type : UpToDateStatusType . Unbuildable , reason : "Declaration file errors" } ) ;
1030
- return resultFlags ;
1030
+ return buildErrors ( declDiagnostics , BuildResultFlags . DeclarationEmitErrors , "Declaration file" ) ;
1031
1031
}
1032
1032
}
1033
1033
1034
1034
// Same as above but now for semantic diagnostics
1035
1035
const semanticDiagnostics = program . getSemanticDiagnostics ( ) ;
1036
1036
if ( semanticDiagnostics . length ) {
1037
- resultFlags |= BuildResultFlags . TypeErrors ;
1038
- reportAndStoreErrors ( proj , semanticDiagnostics ) ;
1039
- projectStatus . setValue ( proj , { type : UpToDateStatusType . Unbuildable , reason : "Semantic errors" } ) ;
1040
- return resultFlags ;
1037
+ return buildErrors ( semanticDiagnostics , BuildResultFlags . TypeErrors , "Semantic" ) ;
1041
1038
}
1042
1039
1043
1040
let newestDeclarationFileContentChangedTime = minimumDate ;
1044
1041
let anyDtsChanged = false ;
1045
- program . emit ( /*targetSourceFile*/ undefined , ( fileName , content , writeBom , onError ) => {
1042
+ let emitDiagnostics : Diagnostic [ ] | undefined ;
1043
+ const reportEmitDiagnostic = ( d : Diagnostic ) => ( emitDiagnostics || ( emitDiagnostics = [ ] ) ) . push ( d ) ;
1044
+ emitFilesAndReportErrors ( program , reportEmitDiagnostic , writeFileName , /*reportSummary*/ undefined , ( fileName , content , writeBom , onError ) => {
1046
1045
let priorChangeTime : Date | undefined ;
1047
1046
if ( ! anyDtsChanged && isDeclarationFile ( fileName ) ) {
1048
1047
// Check for unchanged .d.ts files
@@ -1062,12 +1061,23 @@ namespace ts {
1062
1061
}
1063
1062
} ) ;
1064
1063
1064
+ if ( emitDiagnostics ) {
1065
+ return buildErrors ( emitDiagnostics , BuildResultFlags . EmitErrors , "Emit" ) ;
1066
+ }
1067
+
1065
1068
const status : UpToDateStatus = {
1066
1069
type : UpToDateStatusType . UpToDate ,
1067
1070
newestDeclarationFileContentChangedTime : anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime
1068
1071
} ;
1069
1072
projectStatus . setValue ( proj , status ) ;
1070
1073
return resultFlags ;
1074
+
1075
+ function buildErrors ( diagnostics : ReadonlyArray < Diagnostic > , errorFlags : BuildResultFlags , errorType : string ) {
1076
+ resultFlags |= errorFlags ;
1077
+ reportAndStoreErrors ( proj , diagnostics ) ;
1078
+ projectStatus . setValue ( proj , { type : UpToDateStatusType . Unbuildable , reason : `${ errorType } errors` } ) ;
1079
+ return resultFlags ;
1080
+ }
1071
1081
}
1072
1082
1073
1083
function updateOutputTimestamps ( proj : ParsedCommandLine ) {
0 commit comments