-
Hey everyone, I’ve been hitting a frustrating wall with MobX-State-Tree + TypeScript, and wondering if there’s a clean solution in 2025 — or if this is still just “how it is.” Whenever I define multiple actions inside .actions(self => ({ ... })), I can’t call one action from another without running into TypeScript issues. The problem is that self doesn’t recognize other actions yet during the model construction phase.
I know the usual workarounds: But my pain got worse when I tried using Zustand-style cursors or functions that interact with many actions dynamically — then I end up juggling tons of small action keys and casting types all over the place. It kills DX and makes the code harder to read and refactor. ❗ So the question: Has anyone found a more elegant way to compose MST actions without fighting TypeScript and the self reference? Would love to hear how others are handling this in real-world projects. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think there three options right now:
|
Beta Was this translation helpful? Give feedback.
I think there three options right now:
this
works if the actions are in the sameactions
block.self
works for calling actions in previousactions
blocks. Neither work for actions declared in futureactions
blocks.mobx-quick-tree
orclassy-mst
. Disclaimer: I built the initial implementation of that library and work for gadget 🙂