Typescript is losing the this
type, causing injection to not work
#569
Unanswered
Caceresenzo
asked this question in
Questions
Replies: 1 comment
-
It appears to me that when you are explicitly defining the custom actions with: export interface UsersActions extends ActionTree<RootState, RootState> {
// with specified 'this' type (work fine)
fetchAll: (this: Store<RootState>, context: UserActionContext) => Promise<void>
// without specified 'this' type (work but do not compile)
second(context: UserActionContext): Promise<void>
} then Typescript is then not able to match those against the interface defined by export interface ActionTree<S, R> {
[key: string]: Action<S, R>;
} And treats them as different interface properties with their own types. export interface UsersActions extends ActionTree<RootState, RootState> {} then Vuex is known for not being very type-friendly so I'm not sure if there is better solution than what you found yourself (explicitly specifying |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Describe the bug
Typescript is 'losing' the
this
type.I think this will solve the common issue where
this.$axios
is not working in the store.To Reproduce
Steps to reproduce the behavior:
store/index.js
Expected behavior
To compile without any problem.
Since with its work (compile) fine...
Additional context
The
this
is a effectively a Store.'Provable' with:
(it will print 'Store' x 2)
EDIT: Removed screenshot section
Beta Was this translation helpful? Give feedback.
All reactions