swc-project/swc · error

swc does not support flow types

Error message

swc does not support flow types

What it means

An unreachable!() stub in `Swcify for FlowType` (swcify/typescript.rs:29). Babel's type AST is unified across TypeScript and Flow, so a FlowType node can appear in the type slot; swc only supports TypeScript, and there is no swc AST node for Flow types. The impl returns `Never` and panics whenever a Flow type annotation (from a .js file parsed with Flow syntax) is converted to swc. The FlowType node is the input at fault.

Source

Thrown at crates/swc_estree_compat/src/swcify/typescript.rs:29

use super::Context;
use crate::{swcify::Swcify, Never};

impl Swcify for TSTypeParameterInstantiation {
    type Output = TsTypeParamInstantiation;

    fn swcify(self, ctx: &Context) -> Self::Output {
        TsTypeParamInstantiation {
            span: ctx.span(&self.base),
            params: self.params.swcify(ctx),
        }
    }
}

impl Swcify for FlowType {
    type Output = Never;

    fn swcify(self, _: &Context) -> Self::Output {
        unreachable!("swc does not support flow types")
    }
}

impl Swcify for TypeParamDeclOrNoop {
    type Output = Option<TsTypeParamDecl>;

    fn swcify(self, ctx: &Context) -> Self::Output {
        match self {
            TypeParamDeclOrNoop::Flow(_) => None,
            TypeParamDeclOrNoop::TS(v) => Some(v.swcify(ctx)),
            TypeParamDeclOrNoop::Noop(_) => None,
        }
    }
}

impl Swcify for TSTypeParameterDeclaration {
    type Output = TsTypeParamDecl;

View on GitHub (pinned to 5176682b65)

Solutions

  1. Reject Flow-typed input files before swcification with a clear 'Flow types are not supported' error
  2. Strip Flow type annotations (e.g. via flow-remove-types) before converting the AST
  3. Ensure the Babel parser config uses TypeScript syntax, not Flow, when generating input for swcify
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/swc_estree_compat/src/swcify/typescript.rs:29 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/4dd296f8a6007781. Report an issue: GitHub.