diff --git a/src/apis/watch.ts b/src/apis/watch.ts
index 3f614141..c3cb5a88 100644
--- a/src/apis/watch.ts
+++ b/src/apis/watch.ts
@@ -329,7 +329,8 @@ function createWatcher(
// The subsequent callbacks will redirect to `callback`.
let shiftCallback = (n: any, o: any) => {
shiftCallback = originalCallback
- applyCb(n, o)
+ // o is undefined on the first call
+ applyCb(n, isArray(n) ? [] : o)
}
callback = (n: any, o: any) => {
shiftCallback(n, o)
diff --git a/test/apis/watch.spec.js b/test/apis/watch.spec.js
index 33f5b626..eeb323e6 100644
--- a/test/apis/watch.spec.js
+++ b/test/apis/watch.spec.js
@@ -457,7 +457,7 @@ describe('api/watch', () => {
template: `
{{obj1.a}} {{obj2.a}}
`,
}).$mount()
expect(spy).toBeCalledTimes(1)
- expect(spy).toHaveBeenLastCalledWith([1, 2], undefined)
+ expect(spy).toHaveBeenLastCalledWith([1, 2], [])
obj1.a = 2
obj2.a = 3
@@ -491,7 +491,7 @@ describe('api/watch', () => {
template: `{{a}} {{b}}
`,
}).$mount()
expect(spy).toBeCalledTimes(1)
- expect(spy).toHaveBeenLastCalledWith([1, 1], undefined)
+ expect(spy).toHaveBeenLastCalledWith([1, 1], [])
vm.a = 2
expect(spy).toBeCalledTimes(1)
waitForUpdate(() => {
@@ -553,7 +553,7 @@ describe('api/watch', () => {
},
})
expect(spy).toBeCalledTimes(1)
- expect(spy).toHaveBeenLastCalledWith([1, 1], undefined)
+ expect(spy).toHaveBeenLastCalledWith([1, 1], [])
vm.a = 2
expect(spy).toBeCalledTimes(2)
expect(spy).toHaveBeenLastCalledWith([2, 1], [1, 1])