Back to Vueuse

isDefined

packages/shared/isDefined/index.md

14.3.0252 B
Original Source

isDefined

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>