-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vuex] state field "foo" was overridden by a module with the same name at "foo" #1652
Comments
Essentially duplicate of #1267 You can add your module state in |
That wouldn't make the warning go away, right? |
Yes it will go away. interface RootState {
foo: {} // declare your module state
}
const rootState: any = {
}
const storeConfig: StoreOptions<RootState> = {
modules: {
foo: {}
},
state: rootState
}
const store: Store<RootState> = new Vuex.Store(storeConfig) |
That works, thanks! Can't wait for Vue3 and Typescript just working everywhere 🙂 |
If you don't want to use interface RootState {
foo: {}
}
const rootState = {} as RootState |
Version
3.1.2
Reproduction link
https://gist.github.com/mspoulsen/f3a67e22a76ba124e606a0beae597974
Steps to reproduce
Create a minimal store using the gist.
Then try to access store.state.foo
Result: We get Typescript error: Property 'foo' does not exist on type 'RootState'.
What is expected?
A Typescript error is expected
What is actually happening?
We get the Typescript error and that is the problem
How would I be able to access store.state.foo without adding foo to RootState? And if I do I get this warning in 3.1.2:
[vuex] state field "foo" was overridden by a module with the same name at "foo"
The text was updated successfully, but these errors were encountered: