{"record":{"id":"0504e47147588fe9","repo":"mobxjs/mobx","slug":"mobx-e","errorCode":null,"errorMessage":"[MobX] ${e}","messagePattern":"\\[MobX\\] (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mobx/src/errors.ts","lineNumber":97,"sourceCode":"    },\n    43(annotationType, name, kind) {\n        return (\n            `Cannot apply '${annotationType}' to '${name}' (kind: ${kind}):` +\n            `\\n'${annotationType}' can only be used on properties with a function value.`\n        )\n    },\n    44(annotationType) {\n        return `'${annotationType}' can only be used with 'makeObservable'`\n    }\n} as const\n\nconst errors: typeof niceErrors = __DEV__ ? niceErrors : ({} as any)\n\nexport function die(error: string | keyof typeof errors, ...args: any[]): never {\n    if (__DEV__) {\n        let e: any = typeof error === \"string\" ? error : errors[error]\n        if (typeof e === \"function\") e = e.apply(null, args as any)\n        throw new Error(`[MobX] ${e}`)\n    }\n    throw new Error(\n        `[MobX] minified error nr: ${error}${\n            args.length ? \" \" + args.map(String).join(\",\") : \"\"\n        }. See mobx.js.org/errors`\n    )\n}\n","sourceCodeStart":79,"sourceCodeEnd":105,"githubUrl":"https://github.com/mobxjs/mobx/blob/01211a698b64ea94de8e5f276ff8235fcf8ddf96/packages/mobx/src/errors.ts#L79-L105","documentation":"MobX's internal die() raises all developer-facing invariant violations. In __DEV__ builds it resolves a message key or template from the niceErrors table (optionally formatting it with args) and throws `[MobX] <message>`. It is the single funnel for every 'you used MobX wrong' assertion, so the specific message after [MobX] tells you which invariant was violated.","triggerScenarios":"Any MobX API invariant violation funneled through die(), e.g. calling autorun/reaction/computed with invalid arguments, misusing extendObservable, applying a decorator annotation to the wrong kind of member (assert20223DecoratorType), or passing an error code key from the errors table.","commonSituations":"Misconfigured decorators on non-observable class members; calling APIs with wrong arity/types; state mutations outside actions with enforceActions enabled; version-mismatched usage patterns after upgrading MobX.","solutions":["Read the text after the `[MobX]` prefix — it is the specific violation — and fix the offending call","Look up the error text at mobx.js.org/errors for the detailed explanation","Ensure decorator/annotation targets match their types (observable on properties, action on methods, etc.)","Pass valid arguments: check the API signature for autorun/reaction/computed/extendObservable"],"exampleFix":"// before\ncomputed(() => this.value * 2) // called as method, invalid usage\n// after\nget doubled() { return this.value * 2 } // or makeObservable(this, { doubled: computed })","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"function isMobxError(e: unknown): e is Error & { message: string } {\n    return e instanceof Error && e.message.startsWith('[MobX] ')\n}","tryCatchPattern":"try {\n    autorun(() => { /* ... */ })\n} catch (e) {\n    if (e instanceof Error && e.message.startsWith('[MobX] ')) {\n        console.error('MobX invariant violated:', e.message.replace('[MobX] ', ''))\n    } else throw e\n}","preventionTips":["Read the text after [MobX] and consult mobx.js.org/errors","Validate decorator/annotation targets against MobX's expectations","Keep API arguments matching current-version signatures","Run a dev build in CI to surface invariants with full messages"],"tags":["mobx","invariant","dev-mode"],"backgroundTag":"mobx-invariant-violation","analyzedSha":"01211a698b64ea94de8e5f276ff8235fcf8ddf96","analyzedAt":"2026-08-28T22:10:08.831Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}