diff --git a/src/v3/reactivity/ref.ts b/src/v3/reactivity/ref.ts index 33495806da1..3babc5d9da2 100644 --- a/src/v3/reactivity/ref.ts +++ b/src/v3/reactivity/ref.ts @@ -40,7 +40,6 @@ export function isRef(r: any): r is Ref { return !!(r && (r as Ref).__v_isRef === true) } -export function ref(value: T): T export function ref(value: T): Ref> export function ref(): Ref export function ref(value?: unknown) { diff --git a/types/test/v3/reactivity-test.ts b/types/test/v3/reactivity-test.ts index c357bf8d5c7..a888b86c6a5 100644 --- a/types/test/v3/reactivity-test.ts +++ b/types/test/v3/reactivity-test.ts @@ -15,7 +15,7 @@ import { set, del } from '../../index' -import { IsUnion, describe, expectType } from '../utils' +import { IsUnion, describe, expectType, IsAny } from '../utils' function plainType(arg: number | Ref) { // ref coercing @@ -46,6 +46,10 @@ function plainType(arg: number | Ref) { expectType>(trueRef) expectType(trueRef.value) + // any value should return Ref, not any + const a = ref(1 as any) + expectType>(false) + // tuple expectType<[number, string]>(unref(ref([1, '1']))) @@ -386,7 +390,6 @@ describe('set/del', () => { del([], 'fse', 123) }) - { //#12978 type Steps = { step: '1' } | { step: '2' } @@ -395,4 +398,10 @@ describe('set/del', () => { expectType>(false) expectType>(false) -} \ No newline at end of file +} + +{ + // any value should return Ref, not any + const a = shallowRef(1 as any) + expectType>(false) +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy