@@ -21,6 +21,7 @@ import { queuePostRenderEffect } from './renderer'
2121import { warn } from './warning'
2222import type { ObjectWatchOptionItem } from './componentOptions'
2323import { useSSRContext } from './helpers/useSsrContext'
24+ import type { ComponentPublicInstance } from './componentPublicInstance'
2425
2526export type {
2627 WatchHandle ,
@@ -66,7 +67,9 @@ export function watchPostEffect(
6667 return doWatch (
6768 effect ,
6869 null ,
69- __DEV__ ? extend ( { } , options as any , { flush : 'post' } ) : { flush : 'post' } ,
70+ __DEV__
71+ ? extend ( { } , options as WatchEffectOptions , { flush : 'post' } )
72+ : { flush : 'post' } ,
7073 )
7174}
7275
@@ -77,7 +80,9 @@ export function watchSyncEffect(
7780 return doWatch (
7881 effect ,
7982 null ,
80- __DEV__ ? extend ( { } , options as any , { flush : 'sync' } ) : { flush : 'sync' } ,
83+ __DEV__
84+ ? extend ( { } , options as WatchEffectOptions , { flush : 'sync' } )
85+ : { flush : 'sync' } ,
8186 )
8287}
8388
@@ -243,11 +248,11 @@ export function instanceWatch(
243248 value : WatchCallback | ObjectWatchOptionItem ,
244249 options ?: WatchOptions ,
245250) : WatchHandle {
246- const publicThis = this . proxy as any
251+ const publicThis = this . proxy
247252 const getter = isString ( source )
248253 ? source . includes ( '.' )
249- ? createPathGetter ( publicThis , source )
250- : ( ) => publicThis [ source ]
254+ ? createPathGetter ( publicThis ! , source )
255+ : ( ) => publicThis ! [ source as keyof typeof publicThis ]
251256 : source . bind ( publicThis , publicThis )
252257 let cb
253258 if ( isFunction ( value ) ) {
@@ -262,12 +267,15 @@ export function instanceWatch(
262267 return res
263268}
264269
265- export function createPathGetter ( ctx : any , path : string ) {
270+ export function createPathGetter (
271+ ctx : ComponentPublicInstance ,
272+ path : string ,
273+ ) : ( ) => WatchSource | WatchSource [ ] | WatchEffect | object {
266274 const segments = path . split ( '.' )
267- return ( ) : any => {
275+ return ( ) : WatchSource | WatchSource [ ] | WatchEffect | object => {
268276 let cur = ctx
269277 for ( let i = 0 ; i < segments . length && cur ; i ++ ) {
270- cur = cur [ segments [ i ] ]
278+ cur = cur [ segments [ i ] as keyof typeof cur ]
271279 }
272280 return cur
273281 }
0 commit comments