oxc-project/oxc · error · OxcDiagnostic
`Promise.{prop_name}()` requires 1 argument, but received {a
Error message
`Promise.{prop_name}()` requires 1 argument, but received {args_len}. What it means
Diagnostic from the oxlint rule `promise/valid-params` (plugin `promise`, category `correctness`). It fires when a combinator static (`Promise.race`, `Promise.all`, `Promise.allSettled`, `Promise.any`) or an instance method (`.catch`, `.finally`) is called with an argument count other than exactly 1. The combinators take one iterable of promises; `catch`/`finally` take exactly one callback. Extra arguments are ignored and a missing argument makes the combinator reject or behave unexpectedly (`Promise.all()` with no iterable throws a TypeError at runtime).
Source
Thrown at crates/oxc_linter/src/rules/promise/valid_params.rs:31
OxcDiagnostic::warn(format!(
"`Promise.{prop_name}()` requires 0 or 1 arguments, but received {args_len}."
))
.with_label(span)
}
fn one_or_two_argument_required_diagnostic(
span: Span,
prop_name: &str,
args_len: usize,
) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"`Promise.{prop_name}()` requires 1 or 2 arguments, but received {args_len}."
))
.with_label(span)
}
fn one_argument_required_diagnostic(span: Span, prop_name: &str, args_len: usize) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"`Promise.{prop_name}()` requires 1 argument, but received {args_len}."
))
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct ValidParams;
declare_oxc_lint!(
/// ### What it does
///
/// Enforces the proper number of arguments are passed to Promise functions.
///
/// This rule is generally unnecessary if using TypeScript.
///
/// ### Why is this bad?
///
/// Calling a Promise function with the incorrect number of arguments can lead to unexpectedView on GitHub (pinned to e1e7af627c)
Solutions
- Wrap the promises in a single array/iterable: `Promise.all([a, b, c])`
- Give `catch`/`finally` exactly one callback each; chain multiple `.catch()` calls if needed
- Add `tsc --noEmit` to CI to catch arity errors at compile time
Example fix
// before Promise.all(fetchA(), fetchB(), fetchC()) // after Promise.all([fetchA(), fetchB(), fetchC()])
Defensive patterns
Strategy: type-guard
Validate before calling
npx oxlint --promise/valid-params src/ tsc --noEmit # combinators and catch/finally arity checked via lib signatures
Type guard
// lib signatures guard arity at compile time: // Promise.all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]> // exactly 1 iterable // p.catch(onrejected): Promise<T> // exactly 1 callback // p.finally(onfinally): Promise<T> // exactly 1 callback
Prevention
- Always pass combinators a single array/iterable of promises
- Chain extra `.catch()` calls instead of passing multiple callbacks
- Run `tsc --noEmit` plus `npx oxlint --promise/valid-params` in CI
When it happens
Trigger: `Promise.all(1, 2, 3)` (multiple args instead of one array); `Promise.race(1, 2)`; `somePromise().catch()`; `somePromise().finally(() => {}, () => {})`.
Common situations: Passing promises as varargs instead of an array; refactoring a `then(onSuccess, onFailure)` into `catch` but leaving two callbacks; helper functions forwarding `arguments` into `Promise.all`.
Related errors
- `Promise.{prop_name}()` requires 0 or 1 arguments, but recei
- `Promise.{prop_name}()` requires 1 or 2 arguments, but recei
- Promise executor functions should not be `async`.
- Unexpected `await` inside a loop.
- Avoid nesting promises.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/6ac0087f9c84a6e9.
Report an issue: GitHub.