typescript-with-mobx

typescript-with-mobx is a cursor rule for Cursor from holtwood/awesome-cursorrules-zh. It costs 0 tokens per session (712 once invoked), scanned A, original, MIT.

Guidance for using TypeScript, a version of JavaScript that checks types before the code runs, with MobX stores.

In plain words
What is it for?
Use it to type MobX store properties, actions, and computed values in a TypeScript project.
Why use it?
It catches mismatched state and action values earlier and explains how to configure decorators or MobX's observable helpers.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it to type MobX store properties, actions, and computed values in a TypeScript project.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/holtwood/awesome-cursorrules-zh/typescript-with-mobx
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/holtwood/awesome-cursorrules-zh

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for typescript-with-mobx

README.md
[![agentmods](https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/typescript-with-mobx.svg)](https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/typescript-with-mobx)
Your own site
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/typescript-with-mobx"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/typescript-with-mobx.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 712 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00712
Opus 5 $0.00000 $0.00356
Sonnet 5 $0.00000 $0.00142
Haiku 4.5 $0.00000 $0.00071

Measured 3d ago against content hash 9efc078248d0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

typescript-with-mobx scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/rules/frontend/react/mobx/typescript-with-mobx.mdc · 76 lines

What it actually says

  • 对 MobX 使用 TypeScript 确保类型安全
    • 安装必要的类型定义
      • 对于 MobX 核心库和 mobx-react-lite,通常它们自带 TypeScript 类型定义。如果遇到类型错误,可能需要手动安装 @types/mobx@types/mobx-react-lite(如果它们不是内置的)。
    • 使用装饰器(Decorators)
      • MobX 推荐使用装饰器 (@observable, @action, @computed) 来定义可观察状态、动作和计算值。在 TypeScript 中使用装饰器需要启用相应的编译器选项。
      • tsconfig.json 中启用:
        {
          "compilerOptions": {
            "experimentalDecorators": true,
            "emitDecoratorMetadata": true
          }
        }
        
      • 示例:
        import { makeObservable, observable, action, computed } from 'mobx';
        
        class UserStore {
          @observable name: string = 'John Doe';
          @observable age: number = 30;
        
          constructor() {
            makeObservable(this);
          }
        
          @action
          setAge(newAge: number) {
            this.age = newAge;
          }
        
          @computed
          get isAdult() {
            return this.age >= 18;
          }
        }
        
    • makeObservablemakeAutoObservable
      • 对于 TypeScript 项目,推荐在类的 constructor 中调用 makeObservable(this)makeAutoObservable(this) 来明确地将类属性标记为可观察的。这比使用装饰器更现代,并且在某些环境中可能不需要额外的 Babel 配置。
      • 示例(使用 makeObservable):
        import { makeObservable, observable, action, computed } from 'mobx';
        
        class UserStore {
          name: string = 'John Doe';
          age: number = 30;
        
          constructor() {
            makeObservable(this, {
              name: observable,
              age: observable,
              setAge: action,
              isAdult: computed,
            });
          }
        
          setAge(newAge: number) {
            this.age = newAge;
          }
        
          get isAdult() {
            return this.age >= 18;
          }
        }
        
    • 类型推断与显式类型
      • TypeScript 能够很好地推断 MobX store 的类型,但在复杂场景下,显式地为属性、参数和返回值添加类型注解可以提高代码的可读性和健壮性。
    • 接口和类型别名
      • 定义清晰的接口(interface)或类型别名(type)来描述 MobX store 的状态结构和 action 的参数,有助于保持代码的一致性和可维护性。
    • 与 React 组件结合
      • 在 React 函数式组件中使用 mobx-react-liteobserver HOC 或 useObserver Hook 时,确保组件 props 和 MobX store 访问的类型正确。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 76 lines · 0 tokens per session scan A 9efc078248d0

Subscribe to this mod's changes

typescript-with-mobx is a cursor rule published in the GitHub repository holtwood/awesome-cursorrules-zh (232 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 712 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.