swc-project/swc · error
auto accessor
Error message
auto accessor
What it means
A catch-all arm in `Babelify for ClassMember` (babelify/class.rs:65). The match maps swc class members to Babel ClassBodyEl variants; the arm labeled 'auto accessor' fires for auto-accessor class members (`accessor x = ...`), a decorator-proposal feature whose Babel ESTree representation is not wired up in this conversion, so any ClassMember of that shape reaching the catch-all aborts the babelify pass.
Source
Thrown at crates/swc_estree_compat/src/babelify/class.rs:65
}
impl Babelify for ClassMember {
type Output = ClassBodyEl;
fn babelify(self, ctx: &Context) -> Self::Output {
match self {
ClassMember::Constructor(c) => ClassBodyEl::Method(c.babelify(ctx)),
ClassMember::Method(m) => ClassBodyEl::Method(m.babelify(ctx)),
ClassMember::PrivateMethod(m) => ClassBodyEl::PrivateMethod(m.babelify(ctx)),
ClassMember::ClassProp(p) => ClassBodyEl::Prop(p.babelify(ctx)),
ClassMember::PrivateProp(p) => ClassBodyEl::PrivateProp(p.babelify(ctx)),
ClassMember::TsIndexSignature(s) => ClassBodyEl::TSIndex(s.babelify(ctx)),
ClassMember::Empty(_) => panic!(
"illegal conversion: Cannot convert {:?} to ClassBodyEl",
&self
),
ClassMember::StaticBlock(s) => ClassBodyEl::StaticBlock(s.babelify(ctx)),
ClassMember::AutoAccessor(..) => todo!("auto accessor"),
#[cfg(swc_ast_unknown)]
_ => panic!("unable to access unknown nodes"),
}
}
}
impl Babelify for ClassProp {
type Output = ClassProperty;
fn babelify(self, ctx: &Context) -> Self::Output {
let computed = Some(self.key.is_computed());
ClassProperty {
base: ctx.base(self.span),
key: self.key.babelify(ctx),
value: self
.value
.map(|val| Box::alloc().init(val.babelify(ctx).into())),View on GitHub (pinned to 5176682b65)
Solutions
- Lower auto-accessor members to explicit getter/setter backing-field pairs in an earlier pass before babelifying
- Add a ClassBodyEl mapping for auto accessors if the target ESTree AST supports them
- Reject inputs using accessor syntax with a clear unsupported-feature error instead of panicking
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/swc_estree_compat/src/babelify/class.rs:65 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/0cdacc58aaef739a.
Report an issue: GitHub.