Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/reactivity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ export { readonly, isReadonly, shallowReadonly } from './readonly'
export { set } from './set'
export { del } from './del'

export type { Ref, ToRefs, UnwrapRef, ShallowUnwrapRef } from './ref'
export type {
Ref,
ToRefs,
UnwrapRef,
UnwrapRefSimple,
ShallowUnwrapRef,
} from './ref'
export type { DeepReadonly } from './readonly'
4 changes: 2 additions & 2 deletions src/reactivity/readonly.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reactive, Ref, UnwrapRef } from '.'
import { reactive, Ref, UnwrapRefSimple } from '.'
import { isArray, isPlainObject, isObject, warn, proxy } from '../utils'
import { readonlySet } from '../utils/sets'
import { isReactive, observe } from './reactive'
Expand Down Expand Up @@ -33,7 +33,7 @@ export type DeepReadonly<T> = T extends Builtin
: Readonly<T>

// only unwrap nested ref
type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRef<T>
type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>

/**
* **In @vue/composition-api, `reactive` only provides type-level readonly check**
Expand Down
6 changes: 5 additions & 1 deletion src/reactivity/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export type UnwrapRef<T> = T extends Ref<infer V>
? UnwrapRefSimple<V>
: UnwrapRefSimple<T>

type UnwrapRefSimple<T> = T extends Function | CollectionTypes | BaseTypes | Ref
export type UnwrapRefSimple<T> = T extends
| Function
| CollectionTypes
| BaseTypes
| Ref
? T
: T extends Array<any>
? { [K in keyof T]: UnwrapRefSimple<T[K]> }
Expand Down