[Typescript][Babel] decorators and fields issue #62
Labels
🐛 bug
Something isn't working
👨💻 has PR
A PR that potentially fixes the issue exists
🎈 released
A fix that should close the issue has been released
Hi, thanks for the awesome work on mobx-keystone
I am really excited to move from MST for TS compatibility reasons
However, I've ran into an issue with decorators and class fields
The condensed example is: (sandbox link with full example)
At the time
modelFlow
runsasyncAction
field hasn't been defined yetI believe the root of the problem is Babel's handling of decorators and properties (more info here)
However in TS case the above doesn't work (probably because of this babel issue)
In this case we can use mobx's
decorate
helper and plain assignment call ofmodel()
decorator (see commented out code in the example) but it's a little verboseConsidering that a lot of people (and CRA) nowadays use Babel to transpile their Typescript maybe decorators are not the way to go
Other concern is that decorators proposal has been pretty much redone from scratch and would not be compatible with "legacy" Typescript one
My suggestion would be getting rid of
@model
in favour of"name"
argument ofModel({ })
and shipping function alternatives ofmodelFlow
andmodelAction
Overall I'm not that sold on having decorators in mobx-keystone which is the only downside in comparison with mobx-state-tree I've experienced so far
decorate
approach is alright but for me DX takes a big hit in that caseThe text was updated successfully, but these errors were encountered: