@@ -59,16 +59,16 @@ namespace ts {
59
59
case "include" :
60
60
case "exclude" : {
61
61
const foundExactMatch = updatePaths ( property ) ;
62
- if ( ! foundExactMatch && propertyName === "include" && isArrayLiteralExpression ( property . initializer ) ) {
63
- const includes = mapDefined ( property . initializer . elements , e => isStringLiteral ( e ) ? e . text : undefined ) ;
64
- const matchers = getFileMatcherPatterns ( configDir , /*excludes*/ [ ] , includes , useCaseSensitiveFileNames , currentDirectory ) ;
65
- // If there isn't some include for this, add a new one.
66
- if ( getRegexFromPattern ( Debug . checkDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( oldFileOrDirPath ) &&
67
- ! getRegexFromPattern ( Debug . checkDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( newFileOrDirPath ) ) {
68
- changeTracker . insertNodeAfter ( configFile , last ( property . initializer . elements ) , factory . createStringLiteral ( relativePath ( newFileOrDirPath ) ) ) ;
69
- }
62
+ if ( foundExactMatch || propertyName !== "include" || ! isArrayLiteralExpression ( property . initializer ) ) return ;
63
+ const includes = mapDefined ( property . initializer . elements , e => isStringLiteral ( e ) ? e . text : undefined ) ;
64
+ if ( includes . length === 0 ) return ;
65
+ const matchers : FileMatcherPatterns = getFileMatcherPatterns ( configDir , /*excludes*/ [ ] , includes , useCaseSensitiveFileNames , currentDirectory ) ;
66
+ // If there isn't some include for this, add a new one.
67
+ if ( getRegexFromPattern ( Debug . checkDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( oldFileOrDirPath ) &&
68
+ ! getRegexFromPattern ( Debug . checkDefined ( matchers . includeFilePattern ) , useCaseSensitiveFileNames ) . test ( newFileOrDirPath ) ) {
69
+ changeTracker . insertNodeAfter ( configFile , last ( property . initializer . elements ) , factory . createStringLiteral ( relativePath ( newFileOrDirPath ) ) ) ;
70
70
}
71
- break ;
71
+ return ;
72
72
}
73
73
case "compilerOptions" :
74
74
forEachProperty ( property . initializer , ( property , propertyName ) => {
@@ -85,13 +85,12 @@ namespace ts {
85
85
} ) ;
86
86
}
87
87
} ) ;
88
- break ;
88
+ return ;
89
89
}
90
90
} ) ;
91
91
92
92
function updatePaths ( property : PropertyAssignment ) : boolean {
93
- // Type annotation needed due to #7294
94
- const elements : readonly Expression [ ] = isArrayLiteralExpression ( property . initializer ) ? property . initializer . elements : [ property . initializer ] ;
93
+ const elements = isArrayLiteralExpression ( property . initializer ) ? property . initializer . elements : [ property . initializer ] ;
95
94
let foundExactMatch = false ;
96
95
for ( const element of elements ) {
97
96
foundExactMatch = tryUpdateString ( element ) || foundExactMatch ;
0 commit comments