import { ref, readonly, shallowReadonly, describe, expectError, expectType, Ref, reactive, markRaw } 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) }) describe('should support markRaw', () => { class Test { item = {} as Ref } const test = new Test() const plain = { ref: ref(1) } const r = reactive({ class: { raw: markRaw(test), reactive: test }, plain: { raw: markRaw(plain), reactive: plain } }) expectType>(r.class.raw) // @ts-expect-error it should unwrap expectType>(r.class.reactive) expectType>(r.plain.raw.ref) // @ts-expect-error it should unwrap expectType>(r.plain.reactive.ref) }) describe('shallowReadonly ref unwrap', () => { const r = shallowReadonly({ count: { n: ref(1) } }) // @ts-expect-error r.count = 2 expectType(r.count.n) r.count.n.value = 123 })