chore: add docs links for sfc macros

This commit is contained in:
Evan You 2023-04-02 10:02:33 +08:00
parent c346af2b6a
commit dfb21a5363
1 changed files with 15 additions and 0 deletions

View File

@ -59,6 +59,8 @@ const warnRuntimeUsage = (method: string) =>
* foo?: string * foo?: string
* bar: number * bar: number
* }>() * }>()
*
* @see {@link https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits}
* ``` * ```
* *
* This is only usable inside `<script setup>`, is compiled away in the * This is only usable inside `<script setup>`, is compiled away in the
@ -118,6 +120,8 @@ type BooleanKey<T, K extends keyof T = keyof T> = K extends any
* *
* This is only usable inside `<script setup>`, is compiled away in the * This is only usable inside `<script setup>`, is compiled away in the
* output and should **not** be actually called at runtime. * output and should **not** be actually called at runtime.
*
* @see {@link https://vuejs.org/api/sfc-script-setup.html#defineprops-defineemits}
*/ */
// overload 1: runtime emits w/ array // overload 1: runtime emits w/ array
export function defineEmits<EE extends string = string>( export function defineEmits<EE extends string = string>(
@ -156,6 +160,8 @@ type ShortEmits<T extends Record<string, any>> = UnionToIntersection<
* *
* This is only usable inside `<script setup>`, is compiled away in the * This is only usable inside `<script setup>`, is compiled away in the
* output and should **not** be actually called at runtime. * output and should **not** be actually called at runtime.
*
* @see {@link https://vuejs.org/api/sfc-script-setup.html#defineexpose}
*/ */
export function defineExpose< export function defineExpose<
Exposed extends Record<string, any> = Record<string, any> Exposed extends Record<string, any> = Record<string, any>
@ -165,6 +171,13 @@ export function defineExpose<
} }
} }
/**
* Vue `<script setup>` compiler macro for declaring a component's additional
* options. This should be used only for options that cannot be expressed via
* Composition API - e.g. `inhertiAttrs`.
*
* @see {@link https://vuejs.org/api/sfc-script-setup.html#defineoptions}
*/
export function defineOptions< export function defineOptions<
RawBindings = {}, RawBindings = {},
D = {}, D = {},
@ -232,6 +245,8 @@ type PropsWithDefaults<Base, Defaults> = Base & {
* *
* This is only usable inside `<script setup>`, is compiled away in the output * This is only usable inside `<script setup>`, is compiled away in the output
* and should **not** be actually called at runtime. * and should **not** be actually called at runtime.
*
* @see {@link https://vuejs.org/guide/typescript/composition-api.html#typing-component-props}
*/ */
export function withDefaults<Props, Defaults extends InferDefaults<Props>>( export function withDefaults<Props, Defaults extends InferDefaults<Props>>(
props: Props, props: Props,