( obj: ts.ObjectLiteralExpression, key: string, newValueFn: (oldValue?: ts.Expression) => ts.Expression, )
| 218 | * for the key. |
| 219 | */ |
| 220 | export function updateObjectValueForKey( |
| 221 | obj: ts.ObjectLiteralExpression, |
| 222 | key: string, |
| 223 | newValueFn: (oldValue?: ts.Expression) => ts.Expression, |
| 224 | ): ts.PropertyAssignment { |
| 225 | const existingProp = objectPropertyAssignmentForKey(obj, key); |
| 226 | return ts.factory.createPropertyAssignment( |
| 227 | ts.factory.createIdentifier(key), |
| 228 | newValueFn(existingProp?.initializer), |
| 229 | ); |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Create a new ArrayLiteralExpression, or accept an existing one. |
no test coverage detected