Skip to content

isDefined

Category
Export Size
86 B
Last Changed
3 years ago

Non-nullish checking type guard for Ref.

Usage

ts
import { isDefined } from '@vueuse/core'

const example = ref(Math.random() ? 'example' : undefined) // Ref<string | undefined>

if (isDefined(example))
  example // Ref<string>

Type Declarations

typescript
export declare function isDefined<T>(
  v: Ref<T>,
): v is Ref<Exclude<T, null | undefined>>
export declare function isDefined<T>(
  v: ComputedRef<T>,
): v is ComputedRef<Exclude<T, null | undefined>>
export declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>

Source

SourceDocs

Contributors

Anthony Fu
Glen

Changelog

No recent changes

Released under the MIT License.

BLACK FRIDAY EARLY BIRD
60% OFF + BONUSES:
Any Junior Certification + 2x AI Courses
Get Certified
06
hours
:
38
minutes
:
39
seconds
: