add getters param to arrow fn style getters? #1711
Closed
theoephraim
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Unfortunately this cannot he typed (circular reference), that’s why we use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In vuex, we used to define getters as
(state, getters) => ...
Being able to just use
this
instead to compose getters is nice, but having the 2 different stylesarrowCounterPlusOne: (state) => state.counter + 1
nonArrowCounterPlusOne(): number { return this.counter + 1 }
is a bit weird, and the extra requirement that non-arrow getters must explicitly be typed is a bit annoying. Particularly if you are just shifting some data around (ie converting what was in state into a getter) you must then refactor any getters and add explicit types which can be quite complex...
I'm not sure if it's possible, but if we added back a
getters
param to the arrow-style getters, would we be able to skip the need for explicit typing? It seems perfectly doable from the JS side of things, but the TS types are quite complex...Beta Was this translation helpful? Give feedback.
All reactions