Skip to content

Commit

Permalink
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/instance/state.js
Original file line number Diff line number Diff line change
@@ -202,6 +202,8 @@ function initComputed (vm: Component, computed: Object) {
warn(`The computed property "${key}" is already defined in data.`, vm)
} else if (vm.$options.props && key in vm.$options.props) {
warn(`The computed property "${key}" is already defined as a prop.`, vm)
} else if (vm.$options.methods && key in vm.$options.methods) {
warn(`The computed property "${key}" is already defined as a method.`, vm)
}
}
}
12 changes: 12 additions & 0 deletions test/unit/features/options/computed.spec.js
Original file line number Diff line number Diff line change
@@ -206,6 +206,18 @@ describe('Options computed', () => {
expect(`computed property "a" is already defined as a prop`).toHaveBeenWarned()
})

it('warn conflict with methods', () => {
new Vue({
computed: {
a: () => 2
},
methods: {
a: () => {}
}
})
expect(`computed property "a" is already defined as a method`).toHaveBeenWarned()
})

it('rethrow computed error', () => {
const vm = new Vue({
computed: {

0 comments on commit 3ad60fe

Please sign in to comment.