You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to exclude a field from being made observable using makeObservable with false annotation, as documented in the MobX documentation. The following code should work:
Hello @baruchiro, not part of the dev team, but I can chip in on this.
First of all, the default behaviour of makeObservable is to explicitly set what you want to observe, so in your example count is never observed anyway.
However, if you meant makeAutoObservable instead, which would make count observable, you could exclude it wit the following code
This is because of the behaviour of Typescript to not have private fields in keyof this, which is intended. The current solution although a bit sub-optimal, is probably the best (if not only). Changing that behaviour would probably be a feature request and not a bug.
Intended outcome:
I'm trying to exclude a field from being made observable using
makeObservable
withfalse
annotation, as documented in the MobX documentation. The following code should work:Actual outcome:
I'm getting contradictory TypeScript/ESLint errors:
count
property is not specified inmakeObservable
:count: false
as suggested by the first error:This creates a catch-22 situation where ESLint requires the annotation but then TypeScript doesn't accept it.
How to reproduce the issue:
I've created a minimal reproduction repository that demonstrates this issue:
example-mobx-eslint-bug
Steps to reproduce:
Versions
The text was updated successfully, but these errors were encountered: