You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This breaks Vue's watch function. The first argument of watch's callback becomes a Ref instead of the value, which will cause a runtime error because Property 'value' does not exist on type '{ a: 1; } | { b: 2; }'
The reproduction link provides a good example of this. If you have any questions just ask me.
I've fixed the issue on my fork and the CI actions completed successfully.
You need to change function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>;
to function shallowRef<T extends object>(value: T): [T] extends [Ref] ? T : ShallowRef<T>;
This matches ref's type: function ref<T extends object>(value: T): [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
I think this bug is present in other parts of the code but I'm not sure right now.
The text was updated successfully, but these errors were encountered:
Vue version
3.2.47
Link to minimal reproduction
New reproduction with runtime error: codesandbox.io
typescriptlang.org
Steps to reproduce
shallowRef<{a:1} | {b:2}>({a:1})
as
:shallowRef({a:1} as {a:1} | {b:2})
What is expected?
The return type should be
ShallowRef<{a:1} | {b:2}>
.What is actually happening?
The return type is
ShallowRef<{a:1}> | ShallowRef<{b:2}>
System Info
Any additional comments?
This breaks Vue's watch function. The first argument of watch's callback becomes a Ref instead of the value, which will cause a runtime error because
Property 'value' does not exist on type '{ a: 1; } | { b: 2; }'
The reproduction link provides a good example of this. If you have any questions just ask me.
I've fixed the issue on my fork and the CI actions completed successfully.
You need to change
function shallowRef<T extends object>(value: T): T extends Ref ? T : ShallowRef<T>;
to
function shallowRef<T extends object>(value: T): [T] extends [Ref] ? T : ShallowRef<T>;
This matches ref's type:
function ref<T extends object>(value: T): [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
I think this bug is present in other parts of the code but I'm not sure right now.
The text was updated successfully, but these errors were encountered: