Only copy non error values in array when converting the json

Fixes #27432
This commit is contained in:
Sheetal Nandi
2018-09-28 13:49:00 -07:00
parent 21148b3b0a
commit 0245c2d35e
2 changed files with 125 additions and 10 deletions

View File

@@ -1529,7 +1529,12 @@ namespace ts {
elements: NodeArray<Expression>,
elementOption: CommandLineOption | undefined
): any[] | void {
return (returnValue ? elements.map : elements.forEach).call(elements, (element: Expression) => convertPropertyValueToJson(element, elementOption));
if (!returnValue) {
return elements.forEach(element => convertPropertyValueToJson(element, elementOption));
}
// Filter out invalid values
return filter(elements.map(element => convertPropertyValueToJson(element, elementOption)), v => v !== undefined);
}
function convertPropertyValueToJson(valueExpression: Expression, option: CommandLineOption | undefined): any {