diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 629a2dad9b0..dc446974ae5 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -5,11 +5,15 @@ import { reactive, isProxy, toRaw } from './reactive' import { ComputedRef } from './computed' import { CollectionTypes } from './collectionHandlers' +const RefSymbol = Symbol() + export interface Ref { /** - * @internal + * Type differentiator only. + * We need this to be in public d.ts but don't want it to show up in IDE + * autocomplete, so we use a private Symbol instead. */ - __v_isRef: true + [RefSymbol]: true value: T } diff --git a/test-dts/ref.test-d.ts b/test-dts/ref.test-d.ts index 41dc6ee75c4..e2454e035c8 100644 --- a/test-dts/ref.test-d.ts +++ b/test-dts/ref.test-d.ts @@ -1,5 +1,5 @@ import { expectType } from 'tsd' -import { Ref, ref, isRef, unref } from './index' +import { Ref, ref, isRef, unref, reactive } from './index' function plainType(arg: number | Ref) { // ref coercing @@ -84,3 +84,12 @@ function withSymbol() { } withSymbol() + +const state = reactive({ + foo: { + value: 1, + label: 'bar' + } +}) + +expectType(state.foo.label)