From 2581cfb707f90bdf4128e5d481b99e7c39e198d3 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 23 Jul 2021 15:24:58 -0400 Subject: [PATCH] fix(types): fix types for readonly ref fix #4180 --- packages/reactivity/src/ref.ts | 5 ----- test-dts/reactivity.test-d.ts | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 010fb8d85bd..98cb3e2f376 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -19,11 +19,6 @@ export interface Ref { * @internal */ _shallow?: boolean - - /** - * Deps are maintained locally rather than in depsMap for performance reasons. - */ - dep?: Dep } type RefBase = { diff --git a/test-dts/reactivity.test-d.ts b/test-dts/reactivity.test-d.ts index edccd4fa099..3c35ea58a01 100644 --- a/test-dts/reactivity.test-d.ts +++ b/test-dts/reactivity.test-d.ts @@ -1,9 +1,15 @@ -import { readonly, describe, expectError } from './index' - -describe('should support DeepReadonly', () => { - const r = readonly({ obj: { k: 'v' } }) - // @ts-expect-error - expectError((r.obj = {})) - // @ts-expect-error - expectError((r.obj.k = 'x')) -}) +import { ref, readonly, describe, expectError, expectType, Ref } from './index' + +describe('should support DeepReadonly', () => { + const r = readonly({ obj: { k: 'v' } }) + // @ts-expect-error + expectError((r.obj = {})) + // @ts-expect-error + expectError((r.obj.k = 'x')) +}) + +// #4180 +describe('readonly ref', () => { + const r = readonly(ref({ count: 1 })) + expectType(r) +})