@@ -51,6 +51,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
5151 rebuild ( treeDiff : DiffResult ) {
5252 let pathsToEmit = [ ] ;
5353 let pathsWithErrors = [ ] ;
54+ let errorMessages = [ ] ;
5455
5556 treeDiff . addedPaths . concat ( treeDiff . changedPaths )
5657 . forEach ( ( tsFilePath ) => {
@@ -80,9 +81,10 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
8081 let output = this . tsService . getEmitOutput ( tsFilePath ) ;
8182
8283 if ( output . emitSkipped ) {
83- let errorFound = this . logError ( tsFilePath ) ;
84+ let errorFound = this . collectErrors ( tsFilePath ) ;
8485 if ( errorFound ) {
8586 pathsWithErrors . push ( tsFilePath ) ;
87+ errorMessages . push ( errorFound ) ;
8688 }
8789 } else {
8890 output . outputFiles . forEach ( o => {
@@ -95,7 +97,8 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
9597
9698 if ( pathsWithErrors . length ) {
9799 this . previousRunFailed = true ;
98- var error = new Error ( 'Typescript found errors listed above...' ) ;
100+ var error =
101+ new Error ( 'Typescript found the following errors:\n' + errorMessages . join ( '\n' ) ) ;
99102 error [ 'showStack' ] = false ;
100103 throw error ;
101104 } else if ( this . previousRunFailed ) {
@@ -105,23 +108,25 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
105108 }
106109
107110
108- private logError ( tsFilePath ) {
111+ private collectErrors ( tsFilePath ) : String {
109112 let allDiagnostics = this . tsService . getCompilerOptionsDiagnostics ( )
110113 . concat ( this . tsService . getSyntacticDiagnostics ( tsFilePath ) )
111114 . concat ( this . tsService . getSemanticDiagnostics ( tsFilePath ) ) ;
115+ let errors = [ ] ;
112116
113117 allDiagnostics . forEach ( diagnostic => {
114118 let message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , "\n" ) ;
115119 if ( diagnostic . file ) {
116120 let { line, character} = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
117- console . log ( ` Error ${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ` +
118- `${ message } ` ) ;
121+ errors . push ( ` ${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } ` ) ;
119122 } else {
120- console . log ( ` Error: ${ message } ` ) ;
123+ errors . push ( ` Error: ${ message } ` ) ;
121124 }
122125 } ) ;
123126
124- return ! ! allDiagnostics . length ;
127+ if ( errors . length ) {
128+ return errors . join ( '\n' ) ;
129+ }
125130 }
126131
127132
@@ -148,8 +153,8 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
148153
149154 if ( errorMessages . length ) {
150155 this . previousRunFailed = true ;
151- console . log ( errorMessages . join ( '\n' ) ) ;
152- var error = new Error ( 'Typescript found errors listed above...' ) ;
156+ var error =
157+ new Error ( 'Typescript found the following errors:\n' + errorMessages . join ( '\n' ) ) ;
153158 error [ 'showStack' ] = false ;
154159 throw error ;
155160 } else {
0 commit comments