as destructuring patterns S0
- Stage: Stage 0
- Status: Active
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal introduces as binding patterns to destructuring and pattern matching, allowing a matched value to be bound to a new identifier. The change aims to support both assignment and binding contexts, and will complement the separate pattern matching proposal.
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.
ECMAScript As-Patterns for Matching and Destructuring
Status
Stage: 0
Author: Kat Marchán (npm, @maybekatz)
Champions: Kat Marchán (npm, @maybekatz)
Introduction
When matching non-Identifier values, it's often the case that users might want to also bind that value to an Identifier while doing the matching. For this reason, it's proposed that destructuring be extended with the ability to do this sort of binding. Furthermore, the separate pattern matching proposal will benefit from this change by allowing matching operations against values that are also put into identifiers, since identifiers are irrefutable patterns.
The syntax uses an as keyword, and looks as follows:
Or:
This applies similarly to match:
Note: This syntax is used by
F#.
It's also reminiscent of as syntax in import statements, so there's some
precedent in the language for this sort of binding (import * as bar from './x.js')
The Big Picture
Related Active Proposals
As-Patterns
Syntax
12.15.5 Destructuring Assignment Changes:
13.3.3 Destructuring Binding Patterns Changes:
Match Operator Syntax Changes: