oxc-project/oxc · error · OxcDiagnostic

`nextTick` expects zero or one parameters.

Error message

`nextTick` expects zero or one parameters.

What it means

Diagnostic from the oxlint rule `vue/valid-next-tick`. In `check_call`, if a matched nextTick call has more than one argument (`call.arguments.len() > 1`), the rule reports immediately (after the zero-arg branch, before the await/callback check). Vue's `nextTick` accepts zero or one parameter — a single callback; extra arguments are ignored at runtime, which almost always means the author believed extra params (e.g. error callbacks, `this` bindings à la `promise.then(cb, errCb)`) do something.

Source

Thrown at crates/oxc_linter/src/rules/vue/valid_next_tick.rs:26

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

fn should_be_function_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("`nextTick` is a function.").with_label(span)
}

fn missing_callback_or_await_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Await the Promise returned by `nextTick` or pass a callback function.")
        .with_label(span)
}

fn too_many_parameters_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("`nextTick` expects zero or one parameters.").with_label(span)
}

fn either_await_or_callback_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Either await the Promise or pass a callback function to `nextTick`.")
        .with_label(span)
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Enforce valid `nextTick` function calls.
    ///
    /// ### Why is this bad?
    ///
    /// `nextTick` is a function that takes either a callback or returns a Promise.

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Keep only the callback: `this.$nextTick(callback)`.
  2. If you need error handling, use the Promise form: `await nt().catch(handleError)` or `nt().then(cb).catch(errCb)`.
  3. If you need `this` binding, use an arrow function capturing `this` instead of passing it as an argument.

Example fix

// before
this.$nextTick(callback, anotherCallback);

// after
this.$nextTick(callback);
Defensive patterns

Strategy: validation

Validate before calling

for (const m of src.matchAll(/(?:this\.\$nextTick|Vue\.nextTick|\bnt)\s*\(([^)]*)\)/g)) {
  if (m[1].split(',').filter(s => s.trim()).length > 1) {
    console.warn(`nextTick called with multiple args: ${m[0]}`);
  }
}

Prevention

When it happens

Trigger: `nt(callback, anotherCallback)`, `Vue.nextTick(cb, extra)`, or `this.$nextTick(cb, this)` inside a component instance method in a .vue file. Any matched spelling with 2+ arguments triggers; the diagnostic span is the `nextTick` property/identifier.

Common situations: Treating `nextTick` like a Node-style callback API and passing an error handler; pasting `.then(success, failure)` patterns onto nextTick; passing context as a second argument.

Related errors


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