v3.2.43: initial value of watcher changed from undefined to an empty array
Vue version
3.2.43
Link to minimal reproduction
Steps to reproduce
const total = computed(() => 10);
const totalHistory = ref<Array<string>>([]);
watch(
() => total.value,
(newTotal, oldTotal) => {
totalHistory.value.push(`Total changed from ${oldTotal} to ${newTotal}`);
},
{ immediate: true }
);
This used to log Total changed from undefined to 10
but now logs Total changed from to 10
as oldTotal
is now an empty array.
Change the version to v3.2.42 to this the former behavior
What is expected?
The initial value should be undefined (or a breaking change should be added to the changelog to mention that it is now an empty array)
What is actually happening?
The initial value is an empty array
System Info
System:
OS: macOS 12.6
CPU: (10) arm64 Apple M1 Max
Memory: 21.55 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - ~/.volta/tools/image/node/16.17.0/bin/node
Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
npm: 8.19.2 - ~/.volta/tools/image/npm/8.19.2/bin/npm
Browsers:
Chrome: 107.0.5304.87
Firefox: 106.0.5
Safari: 16.0
npmPackages:
vue: 3.2.43 => 3.2.43
Any additional comments?
No response