@@ -1076,26 +1076,20 @@ namespace ts {
1076
1076
} ) ;
1077
1077
}
1078
1078
1079
- export function getTsConfigObjectLiteralExpression ( tsConfigSourceFile : TsConfigSourceFile ) {
1079
+ export function getTsConfigObjectLiteralExpression ( tsConfigSourceFile : TsConfigSourceFile | undefined ) {
1080
1080
if ( tsConfigSourceFile && tsConfigSourceFile . statements . length ) {
1081
1081
const expression = tsConfigSourceFile . statements [ 0 ] . expression ;
1082
1082
return isObjectLiteralExpression ( expression ) && expression ;
1083
1083
}
1084
1084
}
1085
1085
1086
- export function getTsConfigPropArrayElementValue ( tsConfigSourceFile : TsConfigSourceFile , propKey : string , elementValue : string ) : StringLiteral {
1086
+ export function getTsConfigPropArrayElementValue ( tsConfigSourceFile : TsConfigSourceFile | undefined , propKey : string , elementValue : string ) : StringLiteral | undefined {
1087
1087
const jsonObjectLiteral = getTsConfigObjectLiteralExpression ( tsConfigSourceFile ) ;
1088
- if ( jsonObjectLiteral ) {
1089
- for ( const property of getPropertyAssignment ( jsonObjectLiteral , propKey ) ) {
1090
- if ( isArrayLiteralExpression ( property . initializer ) ) {
1091
- for ( const element of property . initializer . elements ) {
1092
- if ( isStringLiteral ( element ) && element . text === elementValue ) {
1093
- return element ;
1094
- }
1095
- }
1096
- }
1097
- }
1098
- }
1088
+ return jsonObjectLiteral &&
1089
+ firstDefined ( getPropertyAssignment ( jsonObjectLiteral , propKey ) , property =>
1090
+ isArrayLiteralExpression ( property . initializer ) ?
1091
+ find ( property . initializer . elements , ( element ) : element is StringLiteral => isStringLiteral ( element ) && element . text === elementValue ) :
1092
+ undefined ) ;
1099
1093
}
1100
1094
1101
1095
export function getContainingFunction ( node : Node ) : SignatureDeclaration {
0 commit comments