mobxjs/mobx · warning

Found multiple decorators, skipping..

Error message

Found multiple decorators, skipping..

What it means

The codemod can only translate properties/methods carrying a single mobx decorator. When a class member has more than one decorator, it cannot unambiguously rewrite them, so it warns and leaves the property untouched.

Source

Thrown at packages/mobx-undecorate/src/undecorate.ts:389

        }
    }

    function handleProperty(
        property: ClassProperty & /* | or ClassMethod */ {
            decorators: Decorator[]
            accessibility: "private" | "protected" | "public"
        },
        effects: {
            membersMap: [[any, any, boolean, boolean]]
        },
        clazzPath: ASTPath<ClassDeclaration>
    ): ClassProperty | ClassMethod {
        const decorators = property.decorators
        if (!decorators || decorators.length === 0) {
            return property
        }
        if (decorators.length > 1) {
            warn("Found multiple decorators, skipping..", property.decorators[0])
            return property
        }
        const decorator = decorators[0]
        if (!j.Decorator.check(decorator)) {
            return property
        }
        let expr = decorator.expression
        if (j.Identifier.check(expr) && !decoratorsUsed.has(expr.name)) {
            warn(`Found non-mobx decorator @${expr.name}`, decorator)
            return property
        }
        if (property.static) {
            warn(`Static properties are not supported ${property.key.loc?.source}`, property)
            return property
        }

        if (options?.keepDecorators !== true) {
            property.decorators.splice(0)

View on GitHub (pinned to 01211a698b)

Solutions

  1. Manually split the stacked decorators: keep mobx semantics in `makeObservable` and move other decorators (e.g. custom ones) to explicit code.
  2. Run the codemod, then hand-fix the members reported with multiple decorators.
  3. Reduce to a single mobx decorator before running the codemod where the combination was redundant.

Example fix

// before
@observable @reflect count = 1
// after
constructor() { makeObservable(this, { count: observable }) }
// then apply @reflect logic manually, e.g. via a setter or effect
Defensive patterns

Strategy: validation

Validate before calling

const stacked = src.match(/@\w+\s+@\w+/g) || []
if (stacked.length) {
  console.warn('Stacked decorators found, codemod will skip them:', stacked)
}

Type guard

function hasSingleDecorator(member) {
  return !member.decorators || member.decorators.length <= 1
}

Prevention

When it happens

Trigger: `handleProperty` encounters a ClassProperty or ClassMethod whose `decorators.length > 1`, e.g. `@observable @action foo = ...` or `@computed @observable x`.

Common situations: Legacy MobX 4/5 code stacking decorators for logging/serialization alongside mobx decorators, or experimental decorator library mixes.

Related errors


AI-assisted analysis of mobxjs/mobx@01211a698b (2026-08-28). Data as JSON: /api/errors/7537d5c358841f27. Report an issue: GitHub.