Safely traverses object along a typed path tuple and returns the value at
that location, or defaultValue if any step along the way is null or
undefined.
Supports plain objects, arrays (including negative indices), and Maps.
Every position in the path tuple is autocompleted and type-checked by
the language server — including positions that follow numeric array indices.
Paths up to depth 6 have fully inferred return types. Deeper paths compile
without error but return unknown.
Note: passing undefined as defaultValue is indistinguishable from
omitting it — the function cannot tell whether a key is missing or
explicitly holds undefined.
Safely traverses
objectalong a typed path tuple and returns the value at that location, ordefaultValueif any step along the way isnullorundefined.Maps.pathtuple is autocompleted and type-checked by the language server — including positions that follow numeric array indices.unknown.Example: Basic property access
Example: Through an array
Example: With a default value for a missing / undefined key
Example: Negative array index (Python-style)
Example: With a Map
Template: T
The root object type.
Template: D
The type of the fallback default value.
Param: object
The root value to traverse.
Param: path
Tuple of string keys or numeric indices describing the path.
Param: defaultValue
Returned when the resolved value is
undefined.Returns
The value at the given path, or
defaultValueif any step is nullish.