Misstyped reference types
Version
3.0.0-rc.10
Reproduction link
No need
Steps to reproduce
The vue website cites the ref
This is not the same as the real exported types.
Also, this leads to the following 2-line codes to the following result:
1st: Type 'T' is not assignable to type 'UnwrapRef
// First
const result = ref<T>(original);
result.value = original;
// Second
const result2 = ref<T>();
result2.value = original;
What is expected?
Type as seen on the documentation.
interface Ref<T> {
value: T
}
function ref<T>(value: T): Ref<T>
What is actually happening?
Real exported types
export declare function ref<T extends object>(value: T): T extends Ref ? T : Ref<UnwrapRef<T>>;
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
export declare function ref<T = any>(): Ref<T | undefined>;
This is expected, when calling ref on a ref, it doesn't wrap an extra ref layer on it so you can write foo.value instead of foo.value.value