Skip to content

Commit e7e86fd

Browse files
committed
warn computed properties that are already defined as data or props
1 parent 3c02655 commit e7e86fd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/core/instance/state.js

+6
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ function initComputed (vm: Component, computed: Object) {
165165
// at instantiation here.
166166
if (!(key in vm)) {
167167
defineComputed(vm, key, userDef)
168+
} else if (process.env.NODE_ENV !== 'production') {
169+
if (key in vm.$data) {
170+
warn(`The computed property "${key}" is already defined in data.`, vm)
171+
} else if (vm.$options.props && key in vm.$options.props) {
172+
warn(`The computed property "${key}" is already defined as a prop.`, vm)
173+
}
168174
}
169175
}
170176
}

0 commit comments

Comments
 (0)