oxc-project/oxc · error · OxcDiagnostic
`Promise.{prop_name}()` requires 0 or 1 arguments, but recei
Error message
`Promise.{prop_name}()` requires 0 or 1 arguments, but received {args_len}. What it means
Diagnostic from the oxlint rule `promise/valid-params` (plugin `promise`, category `correctness`). It fires when `Promise.resolve(...)` or `Promise.reject(...)` is called with more than one argument (`args_len > 1`). Both statics accept at most one value; extra arguments are silently ignored at runtime, so a multi-argument call almost always means the author expected behavior that does not exist. The rule's own doc notes it is generally unnecessary under TypeScript, where signatures reject extra args at compile time.
Source
Thrown at crates/oxc_linter/src/rules/promise/valid_params.rs:13
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule, utils::is_promise_with_context};
fn zero_or_one_argument_required_diagnostic(
span: Span,
prop_name: &str,
args_len: usize,
) -> OxcDiagnostic {
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!(View on GitHub (pinned to e1e7af627c)
Solutions
- Pass a single value: wrap multiples in a structure (`Promise.resolve([a, b])` or `Promise.resolve({ a, b })`)
- If the arguments are multiple promises, use `Promise.all([...])`
- Add `tsc --noEmit` to CI - TS reports ts(2554) 'Expected 0-1 arguments, but got 2'
Example fix
// before
Promise.resolve(user, settings)
// after
Promise.resolve({ user, settings }) Defensive patterns
Strategy: type-guard
Validate before calling
npx oxlint --promise/valid-params src/ # plus compile-time arity checking: tsc --noEmit # ts(2554): Expected 0-1 arguments, but got 2
Type guard
// TypeScript's lib signature `Promise.resolve<T>(value: T): Promise<Awaited<T>>` // accepts at most one argument, so extra args are a compile error. // Guard: keep files in a tsconfig project and run `tsc --noEmit`.
Prevention
- Pass one value; wrap multiples in an array or object
- Use `Promise.all([...])` for multiple promises
- Run `tsc --noEmit` and oxlint in CI so arity mistakes never land
When it happens
Trigger: `Promise.resolve(1, 2)`; `Promise.resolve({}, function () {}, 1, 2, 3)`; `Promise.reject(1, 2, 3)`.
Common situations: Copy-paste argument lists from call sites into a resolution; intending to pass multiple values and forgetting an array; assuming promise/deferred semantics from other languages or Q/Bluebird.
Related errors
- `Promise.{prop_name}()` requires 1 or 2 arguments, but recei
- `Promise.{prop_name}()` requires 1 argument, but received {a
- 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/ef3d90ca300b231e.
Report an issue: GitHub.