{"record":{"id":"38305c659aa554f8","repo":"swc-project/swc","slug":"classmember","errorCode":null,"errorMessage":"ClassMember::{:?}","messagePattern":"ClassMember::(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_proposal/src/decorators/mod.rs","lineNumber":557,"sourceCode":"                                                    span: DUMMY_SP,\n                                                    arg: Some(value),\n                                                })],\n                                            }),\n                                            ..Default::default()\n                                        }\n                                        .into(),\n                                    }),\n                                    _ => Prop::KeyValue(KeyValueProp {\n                                        key: PropName::Ident(quote_ident!(\"value\")),\n                                        value: Expr::undefined(DUMMY_SP),\n                                    }),\n                                }))))\n                                .collect(),\n                            }\n                            .as_arg(),\n                        )\n                    }\n                    _ => unimplemented!(\"ClassMember::{:?}\", member,),\n                }\n            })\n            .map(Some)\n            .collect();\n\n        make_decorate_call(\n            class.decorators,\n            iter::once({\n                // function(_initialize) {}\n                Function {\n                    span: DUMMY_SP,\n\n                    params: iter::once(initialize.into())\n                        .chain(super_class_ident.map(Pat::from))\n                        .map(|pat| Param {\n                            span: DUMMY_SP,\n                            decorators: Vec::new(),\n                            pat,","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_ecma_transforms_proposal/src/decorators/mod.rs#L539-L575","documentation":"The non-legacy decorator transform builds a descriptors array from every class member. It handles `Method`, `PrivateMethod` and `ClassProp`, skips `Empty`/`TsIndexSignature`, and marks `Constructor` unreachable; all remaining members — private properties (`#x = 1`), static blocks, TS parameter properties, auto-accessors — hit `_ => unimplemented!(\"ClassMember::...\")`. Because it iterates every member, the mere presence of such a member in a decorated class panics even if that member has no decorator.","triggerScenarios":"Use modern (non-legacy) decorators on a class that also contains `#private` fields, `static { ... }` blocks, or TS constructor parameter properties.","commonSituations":"Decorator codebases that adopted `#` private state or static blocks before migrating off legacy decorators; Deno/TS-style classes mixing modern features; upgrading a legacy-decorator project that already used `#` fields.","solutions":["Switch to `jsc.transform.legacyDecorator: true` for classes that mix decorators with `#` fields or static blocks","Replace `#x` private fields with plain (TS `private`) properties in decorated classes, and move static blocks out","Reduce to a minimal repro and report upstream — extending the match arm in decorators/mod.rs is a tractable contribution"],"exampleFix":"// before\n class C {\n   #count = 0;\n   @dec increment() { this.#count++; }\n }\n\n// after\n class C {\n   private count = 0; // or legacyDecorator: true\n   @dec increment() { this.count++; }\n }","handlingStrategy":"validation","validationCode":"// Rust: scan classes for unsupported members before the non-legacy decorator pass\nfn class_has_unsupported_members(c: &Class) -> bool {\n    c.body.iter().any(|m| matches!(m,\n        ClassMember::PrivateProp(..) | ClassMember::StaticBlock(..) | ClassMember::TsParamProp(..)))\n}","typeGuard":"fn decorator_safe_member(m: &ClassMember) -> bool {\n    !matches!(m, ClassMember::PrivateProp(..) | ClassMember::StaticBlock(..) | ClassMember::TsParamProp(..))\n}","tryCatchPattern":null,"preventionTips":["With modern decorators, keep decorated classes free of `#` fields, static blocks, and TS parameter properties","Run a pre-scan on the AST and fall back to `legacyDecorator: true` per file when these members are present"],"tags":["decorators","class-members","proposal","private-fields"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}