@@ -122,9 +122,14 @@ export class AotPlugin implements Tapable {
122
122
const configResult = ts . readConfigFile ( this . _tsConfigPath , ts . sys . readFile ) ;
123
123
if ( configResult . error ) {
124
124
const diagnostic = configResult . error ;
125
- const { line, character} = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
126
125
const message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
127
- throw new Error ( `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ) ;
126
+
127
+ if ( diagnostic . file ) {
128
+ const { line, character} = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
129
+ throw new Error ( `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ) ;
130
+ } else {
131
+ throw new Error ( message ) ;
132
+ }
128
133
}
129
134
130
135
const tsConfigJson = configResult . config ;
@@ -422,14 +427,20 @@ export class AotPlugin implements Tapable {
422
427
423
428
if ( diagnostics . length > 0 ) {
424
429
diagnostics . forEach ( diagnostic => {
425
- const position = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
430
+ const messageText = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
431
+ let message ;
426
432
427
- const sourceText = diagnostic . file . getFullText ( ) ;
428
- let { line, character, fileName} = this . _translateSourceMap ( sourceText ,
429
- diagnostic . file . fileName , position ) ;
433
+ if ( diagnostic . file ) {
434
+ const position = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
430
435
431
- const messageText = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
432
- const message = `${ fileName } (${ line + 1 } ,${ character + 1 } ): ${ messageText } ` ;
436
+ const sourceText = diagnostic . file . getFullText ( ) ;
437
+ let { line, character, fileName} = this . _translateSourceMap ( sourceText ,
438
+ diagnostic . file . fileName , position ) ;
439
+
440
+ message = `${ fileName } (${ line + 1 } ,${ character + 1 } ): ${ messageText } ` ;
441
+ } else {
442
+ message = messageText ;
443
+ }
433
444
434
445
switch ( diagnostic . category ) {
435
446
case ts . DiagnosticCategory . Error :
@@ -501,10 +512,15 @@ export class AotPlugin implements Tapable {
501
512
if ( diagnostics . length > 0 ) {
502
513
const message = diagnostics
503
514
. map ( diagnostic => {
504
- const { line, character} = diagnostic . file . getLineAndCharacterOfPosition (
505
- diagnostic . start ) ;
506
515
const message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
507
- return `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ;
516
+
517
+ if ( diagnostic . file ) {
518
+ const { line, character} = diagnostic . file . getLineAndCharacterOfPosition (
519
+ diagnostic . start ) ;
520
+ return `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ;
521
+ } else {
522
+ return message ;
523
+ }
508
524
} )
509
525
. join ( '\n' ) ;
510
526
0 commit comments