facebook/flow · warning

Skipping_arrow_function

Error message

Skipping_arrow_function

What it means

This is not a panic but a user-facing warning kind (Kind::SkippingArrowFunction) emitted by the annotate-exports codemod. In map_arrow_function (rust_port/crates/flow_codemods/src/annotate_exports.rs:945-985), when a single-parameter arrow function has both its parameter annotation and return annotation missing at the same loc, and that loc is tracked in sig_verification_loc_tys (types recovered from signature verification rather than local inference), the codemod declines to write an annotation: it records the loc in wont_annotate_locs, warns, and returns the function unchanged instead of mapping it via map_function_.

Source

Thrown at rust_port/crates/flow_codemods/src/annotate_exports.rs:977

                    match &inner.annot {
                        types::AnnotationOrHint::Missing(ploc) => Some(ploc),
                        _ => None,
                    }
                }
                _ => None,
            }
        } else {
            None
        };
        let rloc = match &expr.return_ {
            ast::function::ReturnAnnot::Missing(rloc) => Some(rloc),
            _ => None,
        };
        match (ploc, rloc) {
            (Some(ploc), Some(rloc)) if ploc == rloc => {
                if self.sig_verification_loc_tys.contains_key(rloc) {
                    self.mapper.wont_annotate_locs.insert(rloc.clone());
                    self.mapper.acc.warn(
                        loc,
                        &flow_services_code_action::insert_type_utils::warning::Kind::SkippingArrowFunction,
                    );
                }
                expr.clone()
            }
            _ => self.map_function_(loc, expr),
        }
    }

    fn map_program(&mut self, prog: &'ast ast::Program<Loc, Loc>) -> ast::Program<Loc, Loc> {
        let (total_errors_, sig_verification_loc_tys_) =
            signature_verification::collect_annotations(
                self.cctx,
                self.default_any,
                self.max_type_size,
                prog,
            );

View on GitHub (pinned to f88ac94bcf)

Solutions

  1. Treat the warning as advisory: annotate the arrow function manually so the param/return locs no longer coincide
  2. Give the arrow more than one parameter, a rest param, or any annotation so it routes through map_function_ instead of the skip branch
  3. Re-run inference/codemod once the signature-verified types resolve locally so the loc leaves sig_verification_loc_tys
  4. If you build tooling over the codemod, collect SkippingArrowFunction warnings and present the locs to users as a 'not annotated' list

Example fix

// before: skipped with a SkippingArrowFunction warning
export const apply = (x) => transform(x);

// after: explicit annotations let the codemod and readers proceed
export const apply = (x: Input): Output => transform(x);
Defensive patterns

Strategy: fallback

Type guard

// Detect the skipped shape before running the codemod (single missing annot loc shared by param and return)
fn arrow_will_be_skipped(f: &ast::function::Function<Loc, Loc>, sig_locs: &HashMap<Loc, Type>) -> bool {
    let ploc = single_missing_param_annot_loc(f);
    let rloc = missing_return_annot_loc(f);
    matches!((ploc, rloc), (Some(p), Some(r)) if p == r && sig_locs.contains_key(&r))
}

Prevention

When it happens

Trigger: Running annotate-exports over code containing a single-param arrow like (x) => f(x) with no annotations, where the shared loc's type came from signature verification (e.g. libdef or signature-checked types) rather than local inference. Multi-param arrows, arrows with any annotation, or locs not in sig_verification_loc_tys go through map_function_ and are annotated normally.

Common situations: Codemodding modules whose types are pinned by libdefs or cross-module signature checks; exported arrow callbacks that engineers expected to gain types; batch codemod runs where these locs show up as 'not annotated' in the summary.

Related errors


AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20). Data as JSON: /api/errors/27df831ca446875e. Report an issue: GitHub.