Files
fuel-alert/.agents/skills/vueuse-functions/references/extendRef.md
Ovidiu U 4a3ce4cc1d
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
docs: add advanced skills for Vitest, Pinia, and Vue built-ins
Add comprehensive reference documentation for:
- Vitest: environments, projects/workspaces, type testing, vi utilities
- Pinia: HMR, Nuxt integration, SSR setup
- Vue: built-in components (Transition, Teleport, Suspense, KeepAlive) and advanced directives
2026-04-11 16:28:36 +01:00

77 lines
1.5 KiB
Markdown

---
category: Reactivity
---
# extendRef
Add extra attributes to Ref.
## Usage
> Please note the extra attribute will not be accessible in Vue's template.
```ts
import { extendRef } from '@vueuse/core'
import { shallowRef } from 'vue'
const myRef = shallowRef('content')
const extended = extendRef(myRef, { foo: 'extra data' })
extended.value === 'content'
extended.foo === 'extra data'
```
Refs will be unwrapped and be reactive
```ts
import { extendRef } from '@vueuse/core'
// ---cut---
const myRef = shallowRef('content')
const extraRef = shallowRef('extra')
const extended = extendRef(myRef, { extra: extraRef })
extended.value === 'content'
extended.extra === 'extra'
extended.extra = 'new data' // will trigger update
extraRef.value === 'new data'
```
## Type Declarations
```ts
export type ExtendRefReturn<T = any> = Ref<T>
export interface ExtendRefOptions<Unwrap extends boolean = boolean> {
/**
* Is the extends properties enumerable
*
* @default false
*/
enumerable?: boolean
/**
* Unwrap for Ref properties
*
* @default true
*/
unwrap?: Unwrap
}
/**
* Overload 1: Unwrap set to false
*/
export declare function extendRef<
R extends Ref<any>,
Extend extends object,
Options extends ExtendRefOptions<false>,
>(ref: R, extend: Extend, options?: Options): ShallowUnwrapRef<Extend> & R
/**
* Overload 2: Unwrap unset or set to true
*/
export declare function extendRef<
R extends Ref<any>,
Extend extends object,
Options extends ExtendRefOptions,
>(ref: R, extend: Extend, options?: Options): Extend & R
```