Skip to content

Commit b049121

Browse files
committed
fix: show module path when it overwrite a state field
1 parent 62e05cc commit b049121

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function installModule (store, rootState, path, module, hot) {
318318
if (process.env.NODE_ENV !== 'production') {
319319
if (moduleName in parentState) {
320320
console.warn(
321-
`[vuex] state field "${moduleName}" was overridden by a module with the same name`
321+
`[vuex] state field "${moduleName}" was overridden by a module with the same name at "${path.join('.')}"`
322322
)
323323
}
324324
}

test/unit/modules.spec.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,18 +550,22 @@ describe('Modules', () => {
550550
it('module: warn when module overrides state', () => {
551551
spyOn(console, 'warn')
552552
const store = new Vuex.Store({
553-
state () {
554-
return { value: 1 }
555-
},
556553
modules: {
557-
value: {
558-
state: () => 2
554+
foo: {
555+
state () {
556+
return { value: 1 }
557+
},
558+
modules: {
559+
value: {
560+
state: () => 2
561+
}
562+
}
559563
}
560564
}
561565
})
562-
expect(store.state.value).toBe(2)
566+
expect(store.state.foo.value).toBe(2)
563567
expect(console.warn).toHaveBeenCalledWith(
564-
`[vuex] state field "value" was overridden by a module with the same name`
568+
`[vuex] state field "value" was overridden by a module with the same name at "foo.value"`
565569
)
566570
})
567571

0 commit comments

Comments
 (0)