Skip to content

Commit 2b67eec

Browse files
committed
warn computed properties that clash with existing properties (close #4562)
1 parent e809b03 commit 2b67eec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ const computedSharedDefinition = {
112112

113113
function initComputed (vm: Component, computed: Object) {
114114
for (const key in computed) {
115+
/* istanbul ignore if */
116+
if (process.env.NODE_ENV !== 'production' && key in vm) {
117+
warn(
118+
`existing instance property "${key}" will be ` +
119+
`overwritten by a computed property with the same name.`,
120+
vm
121+
)
122+
}
115123
const userDef = computed[key]
116124
if (typeof userDef === 'function') {
117125
computedSharedDefinition.get = makeComputedGetter(userDef, vm)

0 commit comments

Comments
 (0)