diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 5b26aec1..79c2dc52 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -28,7 +28,10 @@ export function isRef(r: any): r is Ref { return r ? r._isRef === true : false } -export function ref(value: T): T extends Ref ? T : Ref> +export function ref( + value: T +): T extends Ref ? T : Ref> +export function ref(value: T): Ref> export function ref(): Ref export function ref(value?: unknown) { return createRef(value) diff --git a/test-dts/ref.test-d.ts b/test-dts/ref.test-d.ts index 7aa6c606..41dc6ee7 100644 --- a/test-dts/ref.test-d.ts +++ b/test-dts/ref.test-d.ts @@ -21,6 +21,16 @@ function plainType(arg: number | Ref) { expectType>(nestedRef) expectType<{ foo: number }>(nestedRef.value) + // ref boolean + const falseRef = ref(false) + expectType>(falseRef) + expectType(falseRef.value) + + // ref true + const trueRef = ref(true) + expectType>(trueRef) + expectType(trueRef.value) + // tuple expectType<[number, string]>(unref(ref([1, '1'])))