oxc-project/oxc · error · OxcDiagnostic

Do not add `then` to an object.

Error message

Do not add `then` to an object.

What it means

Raised by unicorn/no-thenable (object helper) when an object literal or assignment defines a `then` property/method, making it thenable. Thenables are assimilated by `await`/`.then()` and can cause surprising control flow; the faulting input is the `then` definition at the labeled span.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/no_thenable.rs:15

use oxc_ast::{
    AstKind,
    ast::{
        Argument, ArrayExpressionElement, AssignmentExpression, AssignmentTarget, BindingPattern,
        CallExpression, Declaration, Expression, ObjectPropertyKind, PropertyKey, match_expression,
    },
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

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

fn object(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Do not add `then` to an object.")
        .with_help("If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems")
        .with_label(span)
}

fn export(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Do not export `then`.")
        .with_help("If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems")
        .with_label(span)
}

fn class(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Do not add `then` to a class.")
        .with_help("If an object is defined as 'thenable', once it's accidentally used in an await expression, it may cause problems")
        .with_label(span)
}

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

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Rename the property to something like `thenDo` or `after` so the object is not thenable
  2. Move the callback-taking method off the object, e.g. a standalone function taking the object and a callback
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/no_thenable.rs:15 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/2a0ecaae2e4052bb. Report an issue: GitHub.