* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
-export function shallowReadonly<T extends object>(
- target: T
-): Readonly<{ [K in keyof T]: UnwrapNestedRefs<T[K]> }> {
+export function shallowReadonly<T extends object>(target: T): Readonly<T> {
return createReactiveObject(
target,
true,
+import { shallowReadonly } from '@vue/reactivity'
import { ref, readonly, describe, expectError, expectType, Ref } from './index'
describe('should support DeepReadonly', () => {
const r = readonly(ref({ count: 1 }))
expectType<Ref>(r)
})
+
+describe('shallowReadonly ref unwrap', () => {
+ const r = shallowReadonly({ count: { n: ref(1) } })
+ // @ts-expect-error
+ r.count = 2
+ expectType<Ref>(r.count.n)
+ r.count.n.value = 123
+})