@@ -45,6 +45,7 @@ export class Checker {
4545 // will have last result *undefined if no check have been preformed
4646 public lastResults : any ;
4747
48+
4849 constructor ( ) {
4950 // nothing atm
5051 }
@@ -72,7 +73,7 @@ export class Checker {
7273
7374 // get errors and tag them;
7475 this . tsDiagnostics = [ ] ;
75- let optionsErrors = this . program . getOptionsDiagnostics ( ) . map ( ( obj ) => {
76+ let optionsErrors = this . getOptionsDiagnostics ( ) . map ( ( obj ) => {
7677 // tag em so we know for later
7778 ( < any > obj ) . _type = 'options' ;
7879 return obj ;
@@ -81,23 +82,23 @@ export class Checker {
8182
8283
8384
84- let globalErrors = this . program . getGlobalDiagnostics ( ) . map ( ( obj ) => {
85+ let globalErrors = this . getGlobalDiagnostics ( ) . map ( ( obj ) => {
8586 ( < any > obj ) . _type = 'global' ;
8687 return obj ;
8788 } ) ;
8889 this . tsDiagnostics = this . tsDiagnostics . concat ( globalErrors ) ;
8990
9091
9192
92- let syntacticErrors = this . program . getSyntacticDiagnostics ( ) . map ( ( obj ) => {
93+ let syntacticErrors = this . getSyntacticDiagnostics ( ) . map ( ( obj ) => {
9394 ( < any > obj ) . _type = 'syntactic' ;
9495 return obj ;
9596 } ) ;
9697 this . tsDiagnostics = this . tsDiagnostics . concat ( syntacticErrors ) ;
9798
9899
99100
100- let semanticErrors = this . program . getSemanticDiagnostics ( ) . map ( ( obj ) => {
101+ let semanticErrors = this . getSemanticDiagnostics ( ) . map ( ( obj ) => {
101102 ( < any > obj ) . _type = 'semantic' ;
102103 return obj ;
103104 } ) ;
@@ -253,9 +254,9 @@ export class Checker {
253254 }
254255
255256 // print option errors
256- if ( program . getOptionsDiagnostics ( ) . length ) {
257+ if ( this . getOptionsDiagnostics ( ) . length ) {
257258 print ( chalk . underline ( `${ END_LINE } ${ END_LINE } Option errors` ) + chalk . white ( `:${ END_LINE } ` ) ) ;
258- let optionErrorsText = Object . entries ( program . getOptionsDiagnostics ( ) )
259+ let optionErrorsText = Object . entries ( this . getOptionsDiagnostics ( ) )
259260 . map ( ( [ no , err ] ) => {
260261 let text = no + ':' ;
261262 let messageText = ( < any > err ) . messageText ;
@@ -275,9 +276,9 @@ export class Checker {
275276 // print global errors
276277 // todo: this needs testing, how do I create a global error??
277278 /* try {
278- if (program .getGlobalDiagnostics().length) {
279+ if (this .getGlobalDiagnostics().length) {
279280 print(chalk.underline(`${END_LINE}${END_LINE}Global errors`) + chalk.white(`:${END_LINE}`));
280- let optionErrorsText = Object.entries(program .getGlobalDiagnostics())
281+ let optionErrorsText = Object.entries(this .getGlobalDiagnostics())
281282 .map(([no, err]) => {
282283 let text = no + ':';
283284 text = chalk[options.yellowOnGlobal ? 'yellow' : 'red']
@@ -296,10 +297,10 @@ export class Checker {
296297 // time for summary >>>>>
297298
298299 // get errors totals
299- let optionsErrors = program . getOptionsDiagnostics ( ) . length ;
300- let globalErrors = program . getGlobalDiagnostics ( ) . length ;
301- let syntacticErrors = program . getSyntacticDiagnostics ( ) . length ;
302- let semanticErrors = program . getSemanticDiagnostics ( ) . length ;
300+ let optionsErrors = this . getOptionsDiagnostics ( ) . length ;
301+ let globalErrors = this . getGlobalDiagnostics ( ) . length ;
302+ let syntacticErrors = this . getSyntacticDiagnostics ( ) . length ;
303+ let semanticErrors = this . getSemanticDiagnostics ( ) . length ;
303304 let tsLintErrors = lintErrorMessages . length ;
304305 let totalsErrors = optionsErrors + globalErrors + syntacticErrors + semanticErrors + tsLintErrors ;
305306
@@ -524,4 +525,65 @@ export class Checker {
524525 } ;
525526 } ) ;
526527 }
528+
529+
530+
531+ /**
532+ * get diagnostics, filter out of skip errors options is used
533+ *
534+ */
535+ private getOptionsDiagnostics ( ) {
536+
537+ const skipTsErrors = ( this . options . skipTsErrors !== undefined && this . options . skipTsErrors !== null ) ? this . options . skipTsErrors : [ ] ;
538+ // filter error codes in options
539+ return this . program . getOptionsDiagnostics ( ) . filter ( ( option ) => {
540+ if ( skipTsErrors . indexOf ( option . code ) !== - 1 ) {
541+ return false ;
542+ } else {
543+ return true ;
544+ }
545+ } ) ;
546+ }
547+
548+
549+ private getGlobalDiagnostics ( ) {
550+
551+ const skipTsErrors = ( this . options . skipTsErrors !== undefined && this . options . skipTsErrors !== null ) ? this . options . skipTsErrors : [ ] ;
552+ // filter error codes in options
553+ return this . program . getGlobalDiagnostics ( ) . filter ( ( option ) => {
554+ if ( skipTsErrors . indexOf ( option . code ) !== - 1 ) {
555+ return false ;
556+ } else {
557+ return true ;
558+ }
559+ } ) ;
560+ }
561+
562+
563+ private getSyntacticDiagnostics ( ) {
564+
565+ const skipTsErrors = ( this . options . skipTsErrors !== undefined && this . options . skipTsErrors !== null ) ? this . options . skipTsErrors : [ ] ;
566+ // filter error codes in options
567+ return this . program . getSyntacticDiagnostics ( ) . filter ( ( option ) => {
568+ if ( skipTsErrors . indexOf ( option . code ) !== - 1 ) {
569+ return false ;
570+ } else {
571+ return true ;
572+ }
573+ } ) ;
574+ }
575+
576+
577+ private getSemanticDiagnostics ( ) {
578+
579+ const skipTsErrors = ( this . options . skipTsErrors !== undefined && this . options . skipTsErrors !== null ) ? this . options . skipTsErrors : [ ] ;
580+ // filter error codes in options
581+ return this . program . getSemanticDiagnostics ( ) . filter ( ( option ) => {
582+ if ( skipTsErrors . indexOf ( option . code ) !== - 1 ) {
583+ return false ;
584+ } else {
585+ return true ;
586+ }
587+ } ) ;
588+ }
527589}
0 commit comments