Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/isDefined.md
1---2category: Utilities3---45# isDefined67Non-nullish checking type guard for Ref.89## Usage1011```ts12import { isDefined } from '@vueuse/core'1314const example = ref(Math.random() ? 'example' : undefined) // Ref<string | undefined>1516if (isDefined(example))17example // Ref<string>18```1920## Type Declarations2122```ts23export type IsDefinedReturn = boolean24export declare function isDefined<T>(25v: ComputedRef<T>,26): v is ComputedRef<Exclude<T, null | undefined>>27export declare function isDefined<T>(28v: Ref<T>,29): v is Ref<Exclude<T, null | undefined>>30export declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>31```32