File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -930,20 +930,22 @@ namespace ts {
930
930
*/
931
931
function shouldReportDiagnostic ( diagnostic : Diagnostic ) {
932
932
const { file, start } = diagnostic ;
933
- const lineStarts = getLineStarts ( file ) ;
934
- let { line } = computeLineAndCharacterOfPosition ( lineStarts , start ) ;
935
- while ( line > 0 ) {
936
- const previousLineText = file . text . slice ( lineStarts [ line - 1 ] , lineStarts [ line ] ) ;
937
- const result = ignoreDiagnosticCommentRegEx . exec ( previousLineText ) ;
938
- if ( ! result ) {
939
- // non-empty line
940
- return true ;
941
- }
942
- if ( result [ 3 ] ) {
943
- // @ts -ignore
944
- return false ;
933
+ if ( file ) {
934
+ const lineStarts = getLineStarts ( file ) ;
935
+ let { line } = computeLineAndCharacterOfPosition ( lineStarts , start ) ;
936
+ while ( line > 0 ) {
937
+ const previousLineText = file . text . slice ( lineStarts [ line - 1 ] , lineStarts [ line ] ) ;
938
+ const result = ignoreDiagnosticCommentRegEx . exec ( previousLineText ) ;
939
+ if ( ! result ) {
940
+ // non-empty line
941
+ return true ;
942
+ }
943
+ if ( result [ 3 ] ) {
944
+ // @ts -ignore
945
+ return false ;
946
+ }
947
+ line -- ;
945
948
}
946
- line -- ;
947
949
}
948
950
return true ;
949
951
}
You can’t perform that action at this time.
0 commit comments