fix(types): fix ref(false) type to Ref<boolean> (#1028)
This commit is contained in:
parent
e422b8b082
commit
0bdd889156
@ -28,7 +28,10 @@ export function isRef(r: any): r is Ref {
|
|||||||
return r ? r._isRef === true : false
|
return r ? r._isRef === true : false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ref<T>(value: T): T extends Ref ? T : Ref<UnwrapRef<T>>
|
export function ref<T extends object>(
|
||||||
|
value: T
|
||||||
|
): T extends Ref ? T : Ref<UnwrapRef<T>>
|
||||||
|
export function ref<T>(value: T): Ref<UnwrapRef<T>>
|
||||||
export function ref<T = any>(): Ref<T | undefined>
|
export function ref<T = any>(): Ref<T | undefined>
|
||||||
export function ref(value?: unknown) {
|
export function ref(value?: unknown) {
|
||||||
return createRef(value)
|
return createRef(value)
|
||||||
|
@ -21,6 +21,16 @@ function plainType(arg: number | Ref<number>) {
|
|||||||
expectType<Ref<{ foo: number }>>(nestedRef)
|
expectType<Ref<{ foo: number }>>(nestedRef)
|
||||||
expectType<{ foo: number }>(nestedRef.value)
|
expectType<{ foo: number }>(nestedRef.value)
|
||||||
|
|
||||||
|
// ref boolean
|
||||||
|
const falseRef = ref(false)
|
||||||
|
expectType<Ref<boolean>>(falseRef)
|
||||||
|
expectType<boolean>(falseRef.value)
|
||||||
|
|
||||||
|
// ref true
|
||||||
|
const trueRef = ref<true>(true)
|
||||||
|
expectType<Ref<true>>(trueRef)
|
||||||
|
expectType<true>(trueRef.value)
|
||||||
|
|
||||||
// tuple
|
// tuple
|
||||||
expectType<[number, string]>(unref(ref([1, '1'])))
|
expectType<[number, string]>(unref(ref([1, '1'])))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user