Browse Source

chore: add jsdoc for defineSlots (#14566)

Bobbie Goede 1 month ago
parent
commit
d61d8031f0
1 changed files with 16 additions and 0 deletions
  1. 16 0
      packages/runtime-core/src/apiSetupHelpers.ts

+ 16 - 0
packages/runtime-core/src/apiSetupHelpers.ts

@@ -233,6 +233,22 @@ export function defineOptions<
   }
 }
 
+/**
+ * Vue `<script setup>` compiler macro for providing type hints to IDEs for
+ * slot name and slot props type checking.
+ *
+ * Example usage:
+ * ```ts
+ * const slots = defineSlots<{
+ *   default(props: { msg: string }): any
+ * }>()
+ * ```
+ *
+ * This is only usable inside `<script setup>`, is compiled away in the
+ * output and should **not** be actually called at runtime.
+ *
+ * @see {@link https://vuejs.org/api/sfc-script-setup.html#defineslots}
+ */
 export function defineSlots<
   S extends Record<string, any> = Record<string, any>,
 >(): StrictUnwrapSlotsType<SlotsType<S>> {