2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,8 @@ function initComputed (vm: Component, computed: Object) {
202
202
warn ( `The computed property "${ key } " is already defined in data.` , vm )
203
203
} else if ( vm . $options . props && key in vm . $options . props ) {
204
204
warn ( `The computed property "${ key } " is already defined as a prop.` , vm )
205
+ } else if ( vm . $options . methods && key in vm . $options . methods ) {
206
+ warn ( `The computed property "${ key } " is already defined as a method.` , vm )
205
207
}
206
208
}
207
209
}
Original file line number Diff line number Diff line change @@ -206,6 +206,18 @@ describe('Options computed', () => {
206
206
expect ( `computed property "a" is already defined as a prop` ) . toHaveBeenWarned ( )
207
207
} )
208
208
209
+ it ( 'warn conflict with methods' , ( ) => {
210
+ new Vue ( {
211
+ computed : {
212
+ a : ( ) => 2
213
+ } ,
214
+ methods : {
215
+ a : ( ) => { }
216
+ }
217
+ } )
218
+ expect ( `computed property "a" is already defined as a method` ) . toHaveBeenWarned ( )
219
+ } )
220
+
209
221
it ( 'rethrow computed error' , ( ) => {
210
222
const vm = new Vue ( {
211
223
computed : {
0 commit comments