fix(types): fix ref macro types

fix #4499
This commit is contained in:
Evan You
2021-09-04 16:42:39 -04:00
parent 5852cc8d82
commit 815bfcffae
4 changed files with 99 additions and 28 deletions

View File

@@ -4,8 +4,11 @@ import { isFunction, NOOP } from '@vue/shared'
import { ReactiveFlags, toRaw } from './reactive'
import { Dep } from './dep'
declare const ComoutedRefSymbol: unique symbol
export interface ComputedRef<T = any> extends WritableComputedRef<T> {
readonly value: T
[ComoutedRefSymbol]: true
}
export interface WritableComputedRef<T> extends Ref<T> {

View File

@@ -251,7 +251,8 @@ export interface RefUnwrapBailTypes {}
export type ShallowUnwrapRef<T> = {
[K in keyof T]: T[K] extends Ref<infer V>
? V
: T[K] extends Ref<infer V> | undefined // if `V` is `unknown` that means it does not extend `Ref` and is undefined
: // if `V` is `unknown` that means it does not extend `Ref` and is undefined
T[K] extends Ref<infer V> | undefined
? unknown extends V
? undefined
: V | undefined