oxc-project/oxc · error · OxcDiagnostic

Property in `$slots` should be used as function.

Error message

Property in `$slots` should be used as function.

What it means

Emitted by verify in the vue require-slots-as-functions rule when a property of the $slots object is accessed as a plain value (e.g. this.$slots.default) rather than called as a function. In Vue 3 slots are functions returning VNodes, so non-call usage reads stale or incorrect content.

Source

Thrown at crates/oxc_linter/src/rules/vue/require_slots_as_functions.rs:18

use oxc_ast::{
    AstKind,
    ast::{AssignmentTarget, ChainElement, Expression, StaticMemberExpression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::SymbolId;
use oxc_span::{GetSpan, Span};

use crate::{
    AstNode,
    context::LintContext,
    rule::Rule,
    utils::{is_this_object, is_vue_component_options_object},
};

fn require_slots_as_functions_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Property in `$slots` should be used as function.").with_label(span)
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Enforce properties of `$slots` to be used as functions.
    ///
    /// ### Why is this bad?
    ///
    /// In Vue.js 3, `this.$slots.<name>` is a function (slot render function),
    /// not an array of vnodes like in Vue.js 2. Treating slot properties as
    /// values (e.g. `this.$slots.default.filter(...)`) breaks at runtime.
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Call the slot, e.g. this.$slots.default?.() or renderSlots helper
  2. Pass slot functions to h() as children rather than reading them as values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/vue/require_slots_as_functions.rs:18 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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