swc-project/swc · error
swc does not support ObjectPropVal::Pattern({pat:?})
Error message
swc does not support ObjectPropVal::Pattern({pat:?}) What it means
Raised in `Swcify for ObjectProperty` (swcify/expr.rs:533). Babel allows an object property whose value is a Pattern (shorthand/assignment-pattern forms) other than a simple identifier, e.g. `{a = 1} = ...` style defaults or computed destructuring. The code only rewrites PatternLike::Id into a key-value prop; any other pattern shape (AssignmentPattern, RestElement, ObjectPattern, ArrayPattern) has no swc KeyValueProp representation, so it panics. The pattern value that is not a plain identifier is the input at fault.
Source
Thrown at crates/swc_estree_compat/src/swcify/expr.rs:533
span: expr.span(),
expr,
})
}
}
}
}
impl Swcify for ObjectProperty {
type Output = KeyValueProp;
fn swcify(self, ctx: &Context) -> Self::Output {
KeyValueProp {
key: self.key.swcify(ctx),
value: match self.value {
ObjectPropVal::Pattern(pat) => match pat {
PatternLike::Id(i) => i.swcify(ctx).into(),
_ => {
panic!("swc does not support ObjectPropVal::Pattern({pat:?})")
}
},
ObjectPropVal::Expr(e) => e.swcify(ctx),
},
}
}
}
impl Swcify for SequenceExpression {
type Output = SeqExpr;
fn swcify(self, ctx: &Context) -> Self::Output {
SeqExpr {
span: ctx.span(&self.base),
exprs: self.expressions.swcify(ctx),
}
}
}View on GitHub (pinned to 5176682b65)
Solutions
- Before swcifying, verify each ObjectProperty with a Pattern value only wraps a plain Identifier; reject others with a descriptive error
- Extend the conversion to desugar non-identifier shorthand patterns (e.g. assignment defaults) into equivalent swc nodes if the semantics are representable
- Handle the Babel AST stage that produces these pattern-valued properties earlier, so they never reach this conversion
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/swc_estree_compat/src/swcify/expr.rs:533 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/d1f416cb2577d59b.
Report an issue: GitHub.