{"record":{"id":"0c1c2ff69d9317c0","repo":"swc-project/swc","slug":"flow-type","errorCode":null,"errorMessage":"flow type","messagePattern":"flow type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_estree_compat/src/swcify/typescript.rs","lineNumber":109,"sourceCode":"            type_ann: self.type_annotation.swcify(ctx),\n        }\n    }\n}\n\nimpl Swcify for TSType {\n    type Output = Box<TsType>;\n\n    fn swcify(self, _: &Context) -> Self::Output {\n        todo!(\"swc currently does not support importing typescript module from babel\")\n    }\n}\n\nimpl Swcify for SuperTypeParams {\n    type Output = TsTypeParamInstantiation;\n\n    fn swcify(self, ctx: &Context) -> Self::Output {\n        match self {\n            SuperTypeParams::Flow(_) => unimplemented!(\"flow type\"),\n            SuperTypeParams::TS(v) => v.swcify(ctx),\n        }\n    }\n}\n\nimpl Swcify for Access {\n    type Output = Accessibility;\n\n    fn swcify(self, _: &Context) -> Self::Output {\n        match self {\n            Access::Public => Accessibility::Public,\n            Access::Private => Accessibility::Private,\n            Access::Protected => Accessibility::Protected,\n        }\n    }\n}\n\nimpl Swcify for TSEntityName {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_estree_compat/src/swcify/typescript.rs#L91-L127","documentation":"swc_estree_ast models Babel class heritage type parameters as SuperTypeParams with two flavors: TS and Flow. In swc_estree_compat's typescript.rs conversion, the TS variant maps to TsTypeParamInstantiation, but SuperTypeParams::Flow hits unimplemented!(\"flow type\") — Flow generics on an extends clause have no SWC representation. The surrounding code shows related gaps too (TSType conversion is a todo! for babel TS imports), so class-level type info from Babel is only partially convertible.","triggerScenarios":"Calling swcify on a Babel AST parsed with the Flow plugin where any class declaration/expression has type parameters on its heritage clause, e.g. `class C extends React.Component<Props> {}` — the superTypeParams field carries the Flow variant and the match arm panics.","commonSituations":"Converting Flow React codebases whose components extend generic base classes; mixing Flow and TS fixtures through one Babel->SWC pipeline; migration tooling that assumes class shape converts identically across flavors.","solutions":["Detect Flow class heritage type params before conversion (superTypeParams.variant === \"flow\" or any Flow nodes) and skip/convert those files.","Run flow-to-typescript first so heritage generics arrive as the TS variant, which converts fine.","Strip Flow type annotations with Babel preset-flow before handing the AST to swcify (the stripped AST has no superTypeParams).","Implement a lossy Flow -> TsTypeParamInstantiation mapping in crates/swc_estree_compat/src/swcify/typescript.rs."],"exampleFix":"// before: `class App extends React.Component<Props> {}` parsed with [\"flow\"]\nswcify(class_decl.super_type_params, ctx); // panics unimplemented!(\"flow type\")\n\n// after: branch on the flavor before converting\nmatch super_type_params {\n    SuperTypeParams::TS(v) => v.swcify(ctx),\n    SuperTypeParams::Flow(_) => skip_or_convert_via_flow_to_ts(file),\n}","handlingStrategy":"type-guard","validationCode":"export function hasFlowSuperTypeParams(node) {\n  if (!node || typeof node !== \"object\") return false;\n  if (node.superTypeParams && node.superTypeParams.variant !== \"TS\") return true;\n  return Object.values(node).some((v) =>\n    Array.isArray(v) ? v.some(hasFlowSuperTypeParams) : hasFlowSuperTypeParams(v)\n  );\n}\nif (hasFlowSuperTypeParams(babelAst)) routeToFlowConversion(file);","typeGuard":"function classHeritageIsConvertible(classNode) {\n  const p = classNode.superTypeParams;\n  return !p || p.variant === \"TS\";\n}","tryCatchPattern":null,"preventionTips":["For Flow sources, strip types with preset-flow before conversion so heritage type params disappear","Unit-test your converter against both a Flow and a TS generic-class fixture so flavor regressions surface early"],"tags":["flow","babel","generics","class-heritage","ast-conversion","unimplemented"],"backgroundTag":"unsupported-feature-for-language","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}