0👍
Options
- While not solving the problem, we could use "_" as a prefix to indicate variables that should not be accessed. This is a common convention and should be readable for an experienced programmer.
- Not exporting variables created in the store makes them accessible in the store, but not outside, mimicking the effect of a private variable on a class. (thanks to Lawrence Cherone)
- According to this MDN page:
Class fields are public by default, but private class members can be created by using a hash # prefix. The privacy encapsulation of these class features is enforced by JavaScript itself.
- We could use typescript to get access to the private identifier (typescriptlang.org).
Source:stackexchange.com