@@ -92,7 +92,7 @@ export const loadTypeScriptDiagnostic = (tsDiagnostic: ts.Diagnostic) => {
9292 language : 'typescript' ,
9393 header : 'TypeScript' ,
9494 code : tsDiagnostic . code . toString ( ) ,
95- messageText : formatMessageText ( tsDiagnostic ) ,
95+ messageText : flattenDiagnosticMessageText ( tsDiagnostic , tsDiagnostic . messageText ) ,
9696 relFilePath : null ,
9797 absFilePath : null ,
9898 lines : [ ]
@@ -157,11 +157,11 @@ export const loadTypeScriptDiagnostic = (tsDiagnostic: ts.Diagnostic) => {
157157} ;
158158
159159
160- const formatMessageText = ( tsDiagnostic : ts . Diagnostic ) => {
161- let diagnosticChain = tsDiagnostic . messageText ;
162-
163- if ( typeof diagnosticChain === 'string' ) {
164- return diagnosticChain ;
160+ const flattenDiagnosticMessageText = ( tsDiagnostic : ts . Diagnostic , diag : string | ts . DiagnosticMessageChain | undefined ) => {
161+ if ( typeof diag === 'string' ) {
162+ return diag ;
163+ } else if ( diag === undefined ) {
164+ return '' ;
165165 }
166166
167167 const ignoreCodes : number [ ] = [ ] ;
@@ -171,13 +171,13 @@ const formatMessageText = (tsDiagnostic: ts.Diagnostic) => {
171171 }
172172
173173 let result = '' ;
174-
175- while ( diagnosticChain ) {
176- if ( ! ignoreCodes . includes ( diagnosticChain . code ) ) {
177- result += diagnosticChain . messageText + ' ' ;
174+ if ( ! ignoreCodes . includes ( diag . code ) ) {
175+ result = diag . messageText ;
176+ if ( diag . next ) {
177+ for ( const kid of diag . next ) {
178+ result += flattenDiagnosticMessageText ( tsDiagnostic , kid ) ;
179+ }
178180 }
179-
180- diagnosticChain = diagnosticChain . next ;
181181 }
182182
183183 if ( isStencilConfig ) {
0 commit comments