oxc-project/oxc · warning · OxcDiagnostic

Unexpected spread argument.

Error message

Unexpected spread argument.

What it means

The companion diagnostic of vue/no-multiple-slot-args: 'Unexpected spread argument.' — spreading arguments into a scoped-slot call, e.g. `this.$slots.default(...args)`. Slot functions take a single props object, so a spread either forwards multiple positional arguments (ignored by Vue) or hides what is actually being passed, and the rule flags it with the help text 'Do not use spread arguments when calling slot functions.'

Source

Thrown at crates/oxc_linter/src/rules/vue/no_multiple_slot_args.rs:24

    },
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

use crate::{
    AstNode, ast_util::variable_declaration_kind, context::LintContext,
    frameworks::FrameworkOptions, rule::Rule,
};

fn multiple_arguments_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected multiple arguments.")
        .with_help("Pass only one argument to the slot function.")
        .with_label(span)
}

fn spread_argument_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Unexpected spread argument.")
        .with_help("Do not use spread arguments when calling slot functions.")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NoMultipleSlotArgs;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Disallow passing multiple arguments to scoped slots.
    ///
    /// ### Why is this bad?
    ///
    /// Users have to use the arguments in fixed order and cannot omit the ones they don't need.
    /// e.g. if you have a slot that passes in 5 arguments but the user actually only need the last 2 of them,
    /// they will have to declare all 5 just to use the last 2.
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Replace the spread with an explicit single object: `this.$slots.default({ ...props })` — note the braces make it one object argument.
  2. Name the fields you forward so the slot contract is visible at the call site.
  3. If the wrapper truly receives a props object, pass it directly: `slots.default(props)`.
  4. Re-run oxlint to confirm no spread remains at slot call sites.

Example fix

// before
render() {
  return this.$slots.default(...this.item, this.index);
}

// after
render() {
  return this.$slots.default({ item: this.item, index: this.index });
}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Calling a slot function with a spread element in the argument list: `slots.default(...props)`, `this.$scopedSlots.default(...args)` — any SpreadElement at the call site of a scoped slot.

Common situations: Generic slot-forwarding wrappers that collect args and spread them; refactoring from rest parameters; TSX wrappers around arbitrary children slots.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/0a928485621e21a0. Report an issue: GitHub.