File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,24 @@ describe('api: watch', () => {
410
410
expect ( dummy ) . toBe ( 1 )
411
411
} )
412
412
413
+ it ( 'warn and not respect deep option when using effect' , async ( ) => {
414
+ const arr = ref ( [ 1 , [ 2 ] ] )
415
+ let spy = jest . fn ( )
416
+ watchEffect (
417
+ ( ) => {
418
+ spy ( )
419
+ return arr
420
+ } ,
421
+ // @ts -ignore
422
+ { deep : true }
423
+ )
424
+ expect ( spy ) . toHaveBeenCalledTimes ( 1 )
425
+ ; ( arr . value [ 1 ] as Array < number > ) [ 0 ] = 3
426
+ await nextTick ( )
427
+ expect ( spy ) . toHaveBeenCalledTimes ( 1 )
428
+ expect ( `"deep" option is only respected` ) . toHaveBeenWarned ( )
429
+ } )
430
+
413
431
it ( 'onTrack' , async ( ) => {
414
432
const events : DebuggerEvent [ ] = [ ]
415
433
let dummy
Original file line number Diff line number Diff line change @@ -139,13 +139,13 @@ function doWatch(
139
139
if ( immediate !== undefined ) {
140
140
warn (
141
141
`watch() "immediate" option is only respected when using the ` +
142
- `watch(source, callback) signature.`
142
+ `watch(source, callback, options? ) signature.`
143
143
)
144
144
}
145
145
if ( deep !== undefined ) {
146
146
warn (
147
147
`watch() "deep" option is only respected when using the ` +
148
- `watch(source, callback) signature.`
148
+ `watch(source, callback, options? ) signature.`
149
149
)
150
150
}
151
151
}
@@ -186,7 +186,7 @@ function doWatch(
186
186
}
187
187
}
188
188
189
- if ( deep ) {
189
+ if ( cb && deep ) {
190
190
const baseGetter = getter
191
191
getter = ( ) => traverse ( baseGetter ( ) )
192
192
}
You can’t perform that action at this time.
0 commit comments