File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -44,16 +44,24 @@ class NormalizedMessage {
44
44
// message types
45
45
static createFromDiagnostic ( diagnostic : tsTypes . Diagnostic ) {
46
46
const ts : typeof tsTypes = require ( 'typescript' ) ;
47
- const position = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
47
+ let file : string ;
48
+ let line : number ;
49
+ let character : number ;
50
+ if ( diagnostic . file ) {
51
+ file = diagnostic . file . fileName ;
52
+ const position = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
53
+ line = position . line + 1 ;
54
+ character = position . character + 1 ;
55
+ }
48
56
49
57
return new NormalizedMessage ( {
50
58
type : NormalizedMessage . TYPE_DIAGNOSTIC ,
51
59
code : diagnostic . code ,
52
60
severity : ts . DiagnosticCategory [ diagnostic . category ] . toLowerCase ( ) as Severity ,
53
61
content : ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ,
54
- file : diagnostic . file . fileName ,
55
- line : position . line + 1 ,
56
- character : position . character + 1
62
+ file : file ,
63
+ line : line ,
64
+ character : character
57
65
} ) ;
58
66
}
59
67
You can’t perform that action at this time.
0 commit comments