{"record":{"id":"8dc74d447b7f265e","repo":"swc-project/swc","slug":"babel-doesn-t-support-this-right-now","errorCode":null,"errorMessage":"Babel doesn't support this right now.","messagePattern":"Babel doesn't support this right now\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_estree_compat/src/babelify/expr.rs","lineNumber":142,"sourceCode":"                ExprOutput::Expr(Box::alloc().init(Expression::Await(a.babelify(ctx))))\n            }\n            Expr::Paren(p) => {\n                ExprOutput::Expr(Box::alloc().init(Expression::Parenthesized(p.babelify(ctx))))\n            }\n            Expr::JSXElement(e) => {\n                ExprOutput::Expr(Box::alloc().init(Expression::JSXElement(e.babelify(ctx))))\n            }\n            Expr::JSXFragment(f) => {\n                ExprOutput::Expr(Box::alloc().init(Expression::JSXFragment(f.babelify(ctx))))\n            }\n            Expr::TsTypeAssertion(a) => {\n                ExprOutput::Expr(Box::alloc().init(Expression::TSTypeAssertion(a.babelify(ctx))))\n            }\n            Expr::TsNonNull(n) => {\n                ExprOutput::Expr(Box::alloc().init(Expression::TSNonNull(n.babelify(ctx))))\n            }\n            Expr::TsAs(a) => ExprOutput::Expr(Box::alloc().init(Expression::TSAs(a.babelify(ctx)))),\n            Expr::TsInstantiation(..) => unimplemented!(\"Babel doesn't support this right now.\"),\n            Expr::PrivateName(p) => ExprOutput::Private(p.babelify(ctx)),\n\n            // TODO(dwoznicki): how does babel handle these?\n            Expr::JSXMember(_) => panic!(\n                \"illegal conversion: Cannot convert {:?} to ExprOutput - babel has no equivalent\",\n                &self\n            ),\n            Expr::JSXNamespacedName(_) => panic!(\n                \"illegal conversion: Cannot convert {:?} to ExprOutput - babel has no equivalent\",\n                &self\n            ),\n            Expr::JSXEmpty(_) => panic!(\n                \"illegal conversion: Cannot convert {:?} to ExprOutput - babel has no equivalent\",\n                &self\n            ),\n            Expr::TsConstAssertion(_) => panic!(\n                \"illegal conversion: Cannot convert {:?} to ExprOutput - babel has no equivalent\",\n                &self","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_estree_compat/src/babelify/expr.rs#L124-L160","documentation":"When converting SWC AST to Babel/ESTree AST (babelify), Expr::TsInstantiation — a TypeScript 4.7 instantiation expression like `const g = fn<number>;` — has no counterpart modeled in the swc_estree_ast version used here, so the conversion panics with `unimplemented!(\"Babel doesn't support this right now.\")`.","triggerScenarios":"Calling babelify on SWC AST that still contains type instantiation expressions, i.e. source using TS instantiation expressions (`const g = Array<number>;`) was parsed and not stripped before the ESTree conversion.","commonSituations":"Toolchains that parse TypeScript with SWC then hand the AST to Babel-based consumers (codemods, jscodeshift-like tools, babel plugins) without first running the TS-stripping transform; TS 4.7+ codebases.","solutions":["Run the TypeScript strip/transform pass (e.g. swc's typescript pass or resolver-mode strip) before babelify so instantiation expressions are erased","Upgrade swc_estree_compat / swc_estree_ast where a TSTypeInstantiation node may exist","Preprocess source to remove instantiation expressions if you control the input"],"exampleFix":"// before (input reaching babelify)\nconst g = Array<number>;\n\n// after (run TS strip first, or write input without instantiation)\nconst g = Array;","handlingStrategy":"validation","validationCode":"// Rust: reject ASTs containing instantiation expressions before babelify\nuse swc_ecma_visit::{Visit, VisitWith};\nstruct HasTsInstantiation;\nimpl Visit for HasTsInstantiation {\n    fn visit_ts_instantiation(&mut self, n: &swc_ecma_ast::TsInstantiation) {\n        panic!(\"TsInstantiation at {:?} not babelifiable\", n.span);\n    }\n}","typeGuard":"// Walk check before conversion\nfn babelifiable(program: &swc_ecma_ast::Program) -> bool {\n    // after a full typescript-strip pass, no TsInstantiation nodes remain\n    !contains_ts_type_nodes(program)\n}","tryCatchPattern":null,"preventionTips":["Always run the TypeScript strip pass before converting SWC AST to Babel AST","Keep swc_estree_compat/swc_estree_ast versions in sync with the parser","Maintain a round-trip fixture suite (swc parse -> babelify -> swcify) in CI"],"tags":["swc","babel","estree","typescript","ast-conversion"],"backgroundTag":"unimplemented-ast-node-conversion","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}