Closed
Description
Version
3.0.0-alpha.5
Reproduction link
Steps to reproduce
- The typescript playground link shows error
What is expected?
v
is of type number
What is actually happening?
v
is of type Ref<number> | number
This overload of watch
is typed as (simplified)
watch<T>(
source: WatchSource<T>,
cb: WatchCallback<T, T>
)
which is type-unsafe because if source
is Ref<T>
, source.value
is UnwrapRef<T>
, which cannot be passed to WatchCallback<T, T>
.
TypeScript fails to catch the error since the underlying call doWatch
is typed using any
:
doWatch(
source: WatchSource<any>,
cb: WatchCallback<any, any>,
)
Metadata
Metadata
Assignees
Labels
No labels