mirror of https://github.com/vuejs/core.git
fix(types): keep readonly infomation during unwrap refs
This commit is contained in:
parent
2dd2feab9c
commit
c2f762249c
|
@ -486,9 +486,15 @@ function propertyToRef(
|
||||||
export interface RefUnwrapBailTypes {}
|
export interface RefUnwrapBailTypes {}
|
||||||
|
|
||||||
export type ShallowUnwrapRef<T> = {
|
export type ShallowUnwrapRef<T> = {
|
||||||
[K in keyof T]: DistributeRef<T[K]>
|
readonly [K in keyof Pick<T, ReadonlyKeys<T>>]: DistributeRef<T[K]>
|
||||||
|
} & {
|
||||||
|
[K in keyof Omit<T, ReadonlyKeys<T>>]: DistributeRef<T[K]>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReadonlyKeys<O> = {
|
||||||
|
[K in keyof O]: O[K] extends Readonly<any> ? K : never
|
||||||
|
}[keyof O]
|
||||||
|
|
||||||
type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T
|
type DistributeRef<T> = T extends Ref<infer V, unknown> ? V : T
|
||||||
|
|
||||||
export type UnwrapRef<T> =
|
export type UnwrapRef<T> =
|
||||||
|
|
Loading…
Reference in New Issue