types: typing for ref macros
This commit is contained in:
21
packages/runtime-core/src/helpers/refMacros.ts
Normal file
21
packages/runtime-core/src/helpers/refMacros.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Ref, UnwrapRef, ShallowUnwrapRef, ComputedRef } from '@vue/reactivity'
|
||||
|
||||
export function $ref<T>(arg: T | Ref<T>): UnwrapRef<T>
|
||||
export function $ref() {}
|
||||
|
||||
declare const ComputedRefMarker: unique symbol
|
||||
type ComputedRefValue<T> = T & { [ComputedRefMarker]?: any }
|
||||
|
||||
export function $computed<T>(getter: () => T): ComputedRefValue<T>
|
||||
export function $computed() {}
|
||||
|
||||
export function $fromRefs<T>(source: T): ShallowUnwrapRef<T>
|
||||
export function $fromRefs() {
|
||||
return null as any
|
||||
}
|
||||
|
||||
export function $raw<T>(value: ComputedRefValue<T>): ComputedRef<T>
|
||||
export function $raw<T>(value: T): Ref<T>
|
||||
export function $raw() {
|
||||
return null as any
|
||||
}
|
||||
@@ -53,20 +53,19 @@ export { provide, inject } from './apiInject'
|
||||
export { nextTick } from './scheduler'
|
||||
export { defineComponent } from './apiDefineComponent'
|
||||
export { defineAsyncComponent } from './apiAsyncComponent'
|
||||
export { useAttrs, useSlots } from './apiSetupHelpers'
|
||||
|
||||
// <script setup> API ----------------------------------------------------------
|
||||
|
||||
export {
|
||||
// macros runtime, for warnings only
|
||||
// macros runtime, for typing and warnings only
|
||||
defineProps,
|
||||
defineEmits,
|
||||
defineExpose,
|
||||
withDefaults,
|
||||
// internal
|
||||
mergeDefaults,
|
||||
withAsyncContext,
|
||||
useAttrs,
|
||||
useSlots
|
||||
withAsyncContext
|
||||
} from './apiSetupHelpers'
|
||||
|
||||
// Advanced API ----------------------------------------------------------------
|
||||
@@ -345,3 +344,7 @@ const _compatUtils = {
|
||||
export const compatUtils = (__COMPAT__
|
||||
? _compatUtils
|
||||
: null) as typeof _compatUtils
|
||||
|
||||
// Ref macros ------------------------------------------------------------------
|
||||
// for dts generation only
|
||||
export { $ref, $computed, $raw, $fromRefs } from './helpers/refMacros'
|
||||
|
||||
Reference in New Issue
Block a user