{"record":{"id":"18b8357c26351463","repo":"swc-project/swc","slug":"decl","errorCode":null,"errorMessage":"{decl:?}","messagePattern":"\\{decl:\\?\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_typescript/src/transform.rs","lineNumber":1408,"sourceCode":"                        let expr = if exprs.len() == 1 {\n                            exprs.pop().unwrap()\n                        } else {\n                            SeqExpr {\n                                span: DUMMY_SP,\n                                exprs,\n                            }\n                            .into()\n                        };\n\n                        stmts.push(\n                            ExprStmt {\n                                span: var_decl.span,\n                                expr,\n                            }\n                            .into(),\n                        );\n                    }\n                    decl => unreachable!(\"{decl:?}\"),\n                },\n                ModuleItem::ModuleDecl(ModuleDecl::TsImportEquals(decl)) => {\n                    match decl.module_ref {\n                        TsModuleRef::TsEntityName(ts_entity_name) => {\n                            let init = Self::ts_entity_name_to_expr(ts_entity_name);\n\n                            // export impot foo = bar.baz\n                            let stmt = if decl.is_export {\n                                // Foo.foo = bar.baz\n                                let left = id.clone().make_member(decl.id.clone().into());\n                                let expr = init.make_assign_to(op!(\"=\"), left.into());\n\n                                ExprStmt {\n                                    span: decl.span,\n                                    expr: expr.into(),\n                                }\n                                .into()\n                            } else {","sourceCodeStart":1390,"sourceCodeEnd":1426,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_typescript/src/transform.rs#L1390-L1426","documentation":"While erasing TypeScript from module items, the transform handles expected VarDeclarator shapes (identifier names with/without initializers) and panics with `unreachable!(\"{decl:?}\")` for anything else — e.g. a declarator whose name is an array/object binding pattern in a context the eraser does not support (such as ambient `declare` declarations).","triggerScenarios":"TS source or AST containing a variable declarator form the strip transform does not model — classically `declare const {a}: T` / `export declare let [a, b]: T` style ambient destructuring, or hand-built/foreign ASTs with unusual declarators, passed through swc_ecma_transforms_typescript.","commonSituations":"Ambient declaration files (.d.ts generation/stripping pipelines) using destructuring in declare contexts; codemods producing declarators with pattern names; older swc versions before broader declarator coverage.","solutions":["Rewrite the ambient declaration to identifier form (`declare const a: number` instead of `declare const {a}: {a: number}`).","Update swc_core — declarator coverage in the TS transform improves across releases.","If valid tsc-accepted TS reproduces the panic on the latest version, file an swc issue with the snippet."],"exampleFix":"// before: destructuring in an ambient declaration\nexport declare const { a, b }: { a: number; b: string };\n\n// after: identifier declarators\nexport declare const a: number;\nexport declare const b: string;","handlingStrategy":"validation","validationCode":"use swc_ecma_ast::{Pat, VarDeclarator};\nfn declarators_supported(ds: &[VarDeclarator]) -> bool {\n    ds.iter().all(|d| matches!(&d.name, Pat::Ident(_)))\n}\n// especially around ambient/`declare` VarDecls before the TS strip pass","typeGuard":"fn is_simple_declarator(d: &VarDeclarator) -> bool { matches!(&d.name, Pat::Ident(_)) }","tryCatchPattern":null,"preventionTips":["Avoid destructuring in ambient (`declare`) variable declarations.","Keep swc_core current — TS-strip declarator coverage expands over releases.","Validate generated .d.ts-style ASTs for pattern-named declarators before stripping."],"tags":["swc","typescript","strip-types","var-declarator","ambient-declarations","unsupported-ast","panic"],"backgroundTag":"unsupported-ast-node","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}