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 instanceWatch #9371

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

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 89.3 kB (+2.18 kB) 34 kB (+844 B) 30.6 kB (+750 B)
vue.global.prod.js 146 kB (+13.2 kB) 53.2 kB (+3.24 kB) 47.5 kB (+2.78 kB)

Usages

Name Size Gzip Brotli
createApp 49.7 kB (+1.38 kB) 19.5 kB (+452 B) 17.8 kB (+369 B)
createSSRApp 53 kB (+1.46 kB) 20.8 kB (+467 B) 19 kB (+437 B)
defineCustomElement 52 kB (+1.26 kB) 20.2 kB (+425 B) 18.4 kB (+336 B)
overall 63.2 kB (+1.48 kB) 24.4 kB (+526 B) 22.2 kB (+429 B)

@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
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: Ready to merge
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

3 participants