mobxjs/mobx · warning

[mobx:undecorate] ${msg} at (${fileInfo.path}:${node.loc.sta

Error message

[mobx:undecorate] ${msg} at (${fileInfo.path}:${node.loc.start.line}:${node.loc.start.column}):
	${shortline}
	${pad}

What it means

This is the formatted warning the codemod's `warn` helper prints when the AST node has source location info: the message plus file, line, column, the offending source line, and a caret. It is a diagnostic wrapper — the actual reason is the `msg` from a skipped transformation (errors 20-26).

Source

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

            j.ClassMethod.assert(c)
            const firstStatement = c.body.body[0]
            const hasSuper =
                firstStatement &&
                j.ExpressionStatement.check(firstStatement) &&
                j.CallExpression.check(firstStatement.expression) &&
                j.Super.check(firstStatement.expression.callee)
            c.body.body.splice(hasSuper ? 1 : 0, 0, initializeObservablesCall)
        }
    }

    function warn(msg: string, node: Node) {
        if (process.env.NODE_ENV === "test") {
            return
        }
        if (node.loc) {
            const line = lines[node.loc.start.line - 1]
            const shortline = line.replace(/^\s*/, "")
            console.warn(
                `[mobx:undecorate] ${msg} at (${fileInfo.path}:${node.loc.start.line}:${
                    node.loc.start.column
                }):\n\t${shortline}\n\t${"^".padStart(
                    node.loc.start.column + 1 - line.indexOf(shortline),
                    " "
                )}\n`
            )
        } else {
            console.warn(`[mobx:undecorate] ${msg} at (${fileInfo.path})\n`)
        }
    }
}

View on GitHub (pinned to 01211a698b)

Solutions

  1. Read the msg and file:line in the warning, then apply the fix for the underlying issue (see errors 20-26).
  2. Fix the reported location and re-run the codemod until no warnings remain.
  3. Set NODE_ENV=test only to silence warnings during scripted runs, not as a real fix.

Example fix

// before
@observable @computed total = 0   // <- caret points here
// after
constructor() { makeObservable(this, { total: observable }) }
Defensive patterns

Strategy: fallback

Try / catch

const { execSync } = require('child_process')
try {
  execSync('npx mobx-undecorate src/**/*.tsx', { stdio: 'inherit' })
} catch (e) {
  console.error('Codemod reported unhandled failures; fix warnings above and re-run')
}

Prevention

When it happens

Trigger: Any warn() call where `node.loc` is defined; suppressed entirely when `process.env.NODE_ENV === "test"`.

Common situations: Running npx mobx-undecorate on a project and seeing per-file diagnostics pointing at decorators or decorate calls that could not be converted automatically.

Related errors


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