Using mobx' @observable annotation together with mobx-keystone #533
-
Hi, I tried to use the Here is some stripped-down example code. Instead of calling According to https://mobx.js.org/enabling-decorators.html this requires the TypeScript compiler option "experimentalDecorators" to be unset. But then the compiler leaves the Is there a way to use both mobx-keystone class annotations and mobx |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That's because you are using vite, which actually uses esbuild to compile TS files rather than tsc internally, and esbuild does not transpile the new decorators yet (evanw/esbuild#104). If at least the browsers would support them then the lack of transpilation would be ok, but the new standard decorators are still in stage 3 of TC39 and no browsers have yet implemented them (https://caniuse.com/decorators). If you want to use them then you need to either use tsc to compile the code or pass the esbuild code through babel with the new decorators plugin. |
Beta Was this translation helpful? Give feedback.
That's because you are using vite, which actually uses esbuild to compile TS files rather than tsc internally, and esbuild does not transpile the new decorators yet (evanw/esbuild#104).
If at least the browsers would support them then the lack of transpilation would be ok, but the new standard decorators are still in stage 3 of TC39 and no browsers have yet implemented them (https://caniuse.com/decorators).
If you want to use them then you need to either use tsc to compile the code or pass the esbuild code through babel with the new decorators plugin.