Immutably sets a value at a nested path, returning a new root object.
Supports plain objects, arrays (including negative indices), and Maps.
Clones only the containers on the updated path (structural sharing).
Unaffected sibling branches retain their original references.
Missing intermediate containers are auto-created as {} or [] depending
on whether the next key is numeric.
Every position in the path tuple is autocompleted and type-checked by
the language server for known types.
Paths up to depth 6 have fully inferred return types. Deeper paths compile
without error but return unknown.
Note: For dynamic paths or paths that create fields not present in the
original type, the return type falls back to unknown. Use type assertions
when needed.
Immutably sets a value at a nested path, returning a new root object.
Maps.{}or[]depending on whether the next key is numeric.pathtuple is autocompleted and type-checked by the language server for known types.unknown.Example: Basic nested update
Example: Updating array elements
Example: Negative array index (Python-style)
Example: Creating missing intermediate paths
Example: Creating arrays when path contains numeric keys
Example: With a Map
Example: Deeply nested arrays
Template: T
The root object type.
Template: V
The type of the value to set.
Param: object
The root value to update immutably.
Param: path
Tuple of string keys or numeric indices describing the path.
Param: value
The value to set at the given path.
Returns
A new root object with the value set at the specified path. Original object is unchanged.