computed,
ShallowRef
} from 'vue'
-import { expectType, describe, IsUnion } from './utils'
+import { expectType, describe, IsUnion, IsAny } from './utils'
function plainType(arg: number | Ref<number>) {
// ref coercing
// should still unwrap in objects nested in arrays
const arr2 = ref([{ a: ref(1) }]).value
expectType<number>(arr2[0].a)
+
+ // any value should return Ref<any>, not any
+ const a = ref(1 as any)
+ expectType<IsAny<typeof a>>(false)
}
plainType(1)
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
}
+{
+ // any value should return Ref<any>, not any
+ const a = shallowRef(1 as any)
+ expectType<IsAny<typeof a>>(false)
+}
+
describe('shallowRef with generic', <T>() => {
const r = ref({}) as MaybeRef<T>
expectType<ShallowRef<T> | Ref<T>>(shallowRef(r))
* @param value - The object to wrap in the ref.
* @see {@link https://vuejs.org/api/reactivity-core.html#ref}
*/
-export function ref<T extends Ref>(value: T): T
export function ref<T>(value: T): Ref<UnwrapRef<T>>
export function ref<T = any>(): Ref<T | undefined>
export function ref(value?: unknown) {