MCPcopy Create free account
hub / github.com/angular/angular / updateObjectValueForKey

Function updateObjectValueForKey

packages/language-service/src/utils/ts_utils.ts:220–230  ·  view source on GitHub ↗
(
  obj: ts.ObjectLiteralExpression,
  key: string,
  newValueFn: (oldValue?: ts.Expression) => ts.Expression,
)

Source from the content-addressed store, hash-verified

218 * for the key.
219 */
220export 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.

Callers 2

ts_utils_spec.tsFile · 0.90

Calls 2

createIdentifierMethod · 0.80

Tested by

no test coverage detected