From: Evan You Date: Fri, 23 Jul 2021 19:24:58 +0000 (-0400) Subject: fix(types): fix types for readonly ref X-Git-Tag: v3.2.0-beta.5~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2581cfb707f90bdf4128e5d481b99e7c39e198d3;p=thirdparty%2Fvuejs%2Fcore.git fix(types): fix types for readonly ref fix #4180 --- diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 010fb8d85b..98cb3e2f37 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 edccd4fa09..3c35ea58a0 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) +})