Skip to content

Commit

Permalink
fix(types): fix types for readonly ref
Browse files Browse the repository at this point in the history
fix #4180
  • Loading branch information
yyx990803 committed Jul 23, 2021
1 parent 231dafd commit 2581cfb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 0 additions & 5 deletions packages/reactivity/src/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ export interface Ref<T = any> {
* @internal
*/
_shallow?: boolean

/**
* Deps are maintained locally rather than in depsMap for performance reasons.
*/
dep?: Dep
}

type RefBase<T> = {
Expand Down
24 changes: 15 additions & 9 deletions test-dts/reactivity.test-d.ts
Original file line number Diff line number Diff line change
@@ -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<Ref>(r)
})

0 comments on commit 2581cfb

Please sign in to comment.