[AST] PatOrExpr
#5186
-
I think Originally posted by @kdy1 in #5179 (comment) I found a lot of patterns like the following code, swc/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs Lines 1344 to 1376 in 0a13105 If I remove |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
If there is an ident in
After removing Should
|
Beta Was this translation helpful? Give feedback.
-
Another confusing issue.
The |
Beta Was this translation helpful? Give feedback.
-
Concise design from oxc: In swc, this structure is called
This design offers the following advantages:
|
Beta Was this translation helpful? Give feedback.
Concise design from oxc:
AssignmentTarget
OXC Playground
SWC AST
https://github.com/web-infra-dev/oxc/blob/09ebe961d2a6b859f627af86f666d57d28b6a9b3/crates/oxc_ast/src/ast/js.rs#L746-L763
In swc, this structure is called
PatOrExpr
, while in oxc, it is referred toAssignmentTarget
.AssignmentTarget
is an enum with two variants:SimpleAssignmentTarget
andAssignmentTargetPattern
.SimpleAssignmentTarget
wraps an identifier, or member expression (or TypeScript expression).AssignmentTargetPattern
corresponds toPat
in swc.This design offers the following advantages: