Deep Path Properties in Record Literals S1
- Stage: Stage 1
- Status: Active
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
The proposal introduces a new syntax for deep path properties in Record literals, making it possible to describe deeply nested structures more concisely. It supports dot notation and computed keys, and can be combined with spread syntax to update specific nested fields in immutable records and tuples. The proposal defines error behavior: attempting to access a non-existent path in a spread value, or setting a non-number-like key on a tuple, throws a TypeError.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
Deep Path Properties in Record Literals
ECMAScript proposal for deep paths properties for Record literals.
Author:
- Rick Button (Bloomberg)
Champions:
- Rick Button (Bloomberg)
- Robin Ricard (Bloomberg)
Advisors:
- Dan Ehrenberg (Igalia)
Stage: 1, Reached at June 2020 TC39
Overview
Record literals sometimes include deeply nested structures, but the syntax for describing them (either as a fresh value, or based on a previous value via spread syntax) can be cumbersome and/or verbose. Deep path properties for Record literals provides a solution to this problem, by introducing a new syntax for describing deeply nested structures in a more succinct and readable way.
Examples
These examples demonstrate a possible syntax for deep path properties for Record literals.
In the previous example, two counters are incremented, and the "lastUpdate" time is updated in the new record state2.
Without deep path properties, state2 can be created in a few different ways:
A Simple Example
Computed Deep Path Property Keys
It is possible to mix dot syntax with computed keys.
Combining Deep Path Properties with Spread
It is possible to traverse through Tuples.
FAQ
Does deep path properties syntax support objects?
No, the semantics for deep path properties for objects are much less clear than they are for Record, where (because Records are immutable) the semantics are much simpler.
What happens if the deep path property does not exist in the value that is spread?
A TypeError is thrown. For example:
One might expect that a record or tuple somehow "materializes" in these cases, to fill in the path. However, when deep path property syntax is used with spread syntax, there can be ambiguities in what kind of value to "materialize" if the value doesn't already exist. In the latter example, both of the following expansions seem like valid answers:
To keep things simple and minimal, attempting to use a deep path property where the path doesn't already exist in the spread value (whether there is this kind of ambiguity or not) throws a TypeError.
What happens if a deep path property attempts to set a non-number-like key on a Tuple
A TypeError is thrown. For example:
Tuples cannot have non-number-like keys, as they are immutable ordered lists of values and do not have the concept of a "property" (just like a number doesn't have properties). If you attempt to create a Record literal with deep path property syntax that would create a Tuple with a non-number-like key, a TypeError is thrown.
See issue #4 for more discussion.