Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(runtime-core): add OnCleanup parameter type in this.$watch #9371

Merged
merged 12 commits into from
May 27, 2024

Conversation

Alfred-Skyblue
Copy link
Member

The onCleanup parameter is not exposed in the $watch method of ComponentPublicInstance, resulting in a type error.

Expected:

const msg = ref('hello')
// success
getCurrentInstance()!.proxy!.$watch(()=>msg.value, (newVal, oldVal,onCleanup) => {
  console.log(newVal, oldVal)
  onCleanup(() => {
    /* code */
  })
})

Actual:

const msg = ref('hello')
// ts error Target signature provides too few arguments. Expected 3 or more, but got 2.
getCurrentInstance()!.proxy!.$watch(()=>msg.value, (newVal, oldVal,onCleanup) => {
  console.log(newVal, oldVal)
  onCleanup(() => {
    /* code */
  })
})

@github-actions
Copy link

github-actions bot commented Oct 10, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.8 kB 34.5 kB 31.1 kB
vue.global.prod.js 148 kB 53.7 kB 48 kB

Usages

Name Size Gzip Brotli
createApp 50.8 kB 19.9 kB 18.1 kB
createSSRApp 54.1 kB 21.2 kB 19.3 kB
defineCustomElement 53.1 kB 20.6 kB 18.8 kB
overall 64.6 kB 24.9 kB 22.6 kB

@Alfred-Skyblue Alfred-Skyblue changed the title types(apiWatch): add OnCleanup parameter type in instanceWatch types(runtime-core): add OnCleanup parameter type in instanceWatch Oct 10, 2023
Copy link
Member

@pikax pikax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pikax pikax added ready to merge The PR is ready to be merged. 🧹 p1-chore Priority 1: this doesn't change code behavior. labels Oct 13, 2023
@haoqunjiang
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented May 27, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue failure success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@haoqunjiang haoqunjiang merged commit 521988d into vuejs:main May 27, 2024
11 checks passed
@haoqunjiang haoqunjiang changed the title types(runtime-core): add OnCleanup parameter type in instanceWatch types(runtime-core): add OnCleanup parameter type in this.$watch May 27, 2024
@Alfred-Skyblue Alfred-Skyblue deleted the types/instanceWatch branch May 28, 2024 02:04
Copy link

netlify bot commented May 28, 2024

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit 045049b
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/6654af7f6d4b670008bab97e

lynxlangya pushed a commit to lynxlangya/core that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧹 p1-chore Priority 1: this doesn't change code behavior. ready to merge The PR is ready to be merged. scope: reactivity scope: types
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants