-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Type-unsafe behavior of watch #759
Comments
Seems to be a problem in |
Oops, didn't see a commit closed this issue. |
I see this specific instance of the issue is fixed in |
That's a good catch. I think ref value unwrapping should happen in its creation signature - see d4c6957 |
Version
3.0.0-alpha.5
Reproduction link
http://www.typescriptlang.org/v2/en/play?ts=3.7.5#code/JYWwDg9gTgLgBAbzlApgMwDRwO4EMYDGAFlgErpwC+caUEIcA5AAIBuArigPRTsB2MUCgC0BaCkYAoSWL4BneGjgBeOAAooALjjk0AHj7sQAIxRQAfHAA+cQybMBKFZYSS4cWQo8QzBFABMVZHQNBzccfGI1MV8ArDVWJ2UXcPcuLjgAUQAPFDAUAhhtVjhgOVsjUyhUuHS4AEFC9lwAG2LS8t0DSrNLGzsqms8IFpQAOhaIAHMEuABqOABGMPdKMMpJIA
Steps to reproduce
What is expected?
v
is of typenumber
What is actually happening?
v
is of typeRef<number> | number
This overload of
watch
is typed as (simplified)which is type-unsafe because if
source
isRef<T>
,source.value
isUnwrapRef<T>
, which cannot be passed toWatchCallback<T, T>
.TypeScript fails to catch the error since the underlying call
doWatch
is typed usingany
:The text was updated successfully, but these errors were encountered: