From: pikax Date: Sat, 4 Jan 2020 10:10:30 +0000 (+0000) Subject: types: improve type error logging and nest ref types X-Git-Tag: v3.0.0-alpha.13~2^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=14f1814292c8586802e4d1c6484a115e4000ce0f;p=thirdparty%2Fvuejs%2Fcore.git types: improve type error logging and nest ref types --- diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index e2ff79e185..3c3159ce30 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -84,18 +84,20 @@ function toProxyRef( type UnwrapArray = { [P in keyof T]: UnwrapRef } -// Recursively unwraps nested value bindings. -export type UnwrapRef = { - cRef: T extends ComputedRef ? UnwrapRef : T - ref: T extends Ref ? UnwrapRef : T - array: T extends Array ? Array> & UnwrapArray : T - object: { [K in keyof T]: UnwrapRef } -}[T extends ComputedRef - ? 'cRef' - : T extends Ref - ? 'ref' - : T extends Array - ? 'array' - : T extends Function | CollectionTypes - ? 'ref' // bail out on types that shouldn't be unwrapped - : T extends object ? 'object' : 'ref'] +type UnwrapProp = T extends ComputedRef + ? UnwrapRef + : T extends Ref + ? UnwrapRef + : T extends Function | CollectionTypes + ? T + : T extends object + ? UnwrapObject + : T extends Array ? Array> & UnwrapArray : T + +type UnwrapObject = { [K in keyof T]: UnwrapProp } + +export type UnwrapRef = T extends object + ? UnwrapObject + : T extends Function | CollectionTypes + ? T + : T extends Array ? Array> & UnwrapArray : T