@@ -590,10 +590,10 @@ namespace ts {
590590 }
591591 }
592592 else if ( id === "include" ) {
593- options . include = isArray ( jsonTypingOptions [ id ] ) ? < string [ ] > jsonTypingOptions [ id ] : [ ] ;
593+ options . include = ConvertJsonOptionToStringArray ( id , jsonTypingOptions [ id ] , errors ) ;
594594 }
595595 else if ( id === "exclude" ) {
596- options . exclude = isArray ( jsonTypingOptions [ id ] ) ? < string [ ] > jsonTypingOptions [ id ] : [ ] ;
596+ options . exclude = ConvertJsonOptionToStringArray ( id , jsonTypingOptions [ id ] , errors ) ;
597597 }
598598 else {
599599 errors . push ( createCompilerDiagnostic ( Diagnostics . Unknown_typing_option_0 , id ) ) ;
@@ -636,8 +636,8 @@ namespace ts {
636636 }
637637 }
638638 if ( opt . isFilePath ) {
639- value = normalizePath ( combinePaths ( basePath , value ) ) ;
640- if ( value === "" ) {
639+ value = normalizePath ( combinePaths ( basePath , value ) ) ;
640+ if ( value === "" ) {
641641 value = "." ;
642642 }
643643 }
@@ -654,4 +654,28 @@ namespace ts {
654654
655655 return { options, errors } ;
656656 }
657+
658+ function ConvertJsonOptionToStringArray ( optionName : string , optionJson : any , errors : Diagnostic [ ] , func ?: ( element : string ) => string ) : string [ ] {
659+ let items : string [ ] = [ ] ;
660+ let invalidOptionType = false ;
661+ if ( ! isArray ( optionJson ) ) {
662+ invalidOptionType = true ;
663+ }
664+ else {
665+ for ( const element of < any [ ] > optionJson ) {
666+ if ( typeof element === "string" ) {
667+ const item = func ? func ( element ) : element ;
668+ items . push ( item ) ;
669+ }
670+ else {
671+ invalidOptionType = true ;
672+ break ;
673+ }
674+ }
675+ }
676+ if ( invalidOptionType ) {
677+ errors . push ( createCompilerDiagnostic ( Diagnostics . Option_0_should_have_array_of_strings_as_a_value , optionName ) ) ;
678+ }
679+ return items ;
680+ }
657681}
0 commit comments