@@ -21,6 +21,7 @@ import { queuePostRenderEffect } from './renderer'
2121import { warn } from './warning'
2222import type { ObjectWatchOptionItem } from './componentOptions'
2323import { useSSRContext } from './helpers/useSsrContext'
24+ import { ComponentPublicInstance } from '@vue/runtime-core'
2425
2526export type {
2627 WatchHandle ,
@@ -66,7 +67,7 @@ export function watchPostEffect(
6667 return doWatch (
6768 effect ,
6869 null ,
69- __DEV__ ? extend ( { } , options as any , { flush : 'post' } ) : { flush : 'post' } ,
70+ __DEV__ ? extend ( { } , options as WatchEffectOptions , { flush : 'post' } ) : { flush : 'post' } ,
7071 )
7172}
7273
@@ -77,7 +78,7 @@ export function watchSyncEffect(
7778 return doWatch (
7879 effect ,
7980 null ,
80- __DEV__ ? extend ( { } , options as any , { flush : 'sync' } ) : { flush : 'sync' } ,
81+ __DEV__ ? extend ( { } , options as WatchEffectOptions , { flush : 'sync' } ) : { flush : 'sync' } ,
8182 )
8283}
8384
@@ -243,11 +244,11 @@ export function instanceWatch(
243244 value : WatchCallback | ObjectWatchOptionItem ,
244245 options ?: WatchOptions ,
245246) : WatchHandle {
246- const publicThis = this . proxy as any
247+ const publicThis = this . proxy
247248 const getter = isString ( source )
248249 ? source . includes ( '.' )
249- ? createPathGetter ( publicThis , source )
250- : ( ) => publicThis [ source ]
250+ ? createPathGetter ( publicThis ! , source )
251+ : ( ) => publicThis ! [ source as keyof typeof publicThis ]
251252 : source . bind ( publicThis , publicThis )
252253 let cb
253254 if ( isFunction ( value ) ) {
@@ -262,12 +263,12 @@ export function instanceWatch(
262263 return res
263264}
264265
265- export function createPathGetter ( ctx : any , path : string ) {
266+ export function createPathGetter ( ctx : ComponentPublicInstance , path : string ) : WatchSource | WatchSource [ ] | WatchEffect | object {
266267 const segments = path . split ( '.' )
267- return ( ) : any => {
268+ return ( ) : WatchSource | WatchSource [ ] | WatchEffect | object => {
268269 let cur = ctx
269270 for ( let i = 0 ; i < segments . length && cur ; i ++ ) {
270- cur = cur [ segments [ i ] ]
271+ cur = cur [ segments [ i ] as keyof typeof cur ]
271272 }
272273 return cur
273274 }
0 commit comments