小编sba*_*kht的帖子

如何在没有 typescript 的情况下在 vue3 props 上使用 jsdoc?

const props = defineProps({
items: {
    /** @type {{new(): Color[] }} */
    type: Array,
    required: true,
  },
  selectedColor: {
    type: Object,
    required: true,
  },
  composable: {
    type: Function,
    required: true
  }
})
Run Code Online (Sandbox Code Playgroud)

我们不使用打字稿,所以我尝试仅使用 jsdoc 和打字稿接口文件添加类型。

项目正确键入为颜色数组。如何将 selectedColor 的类型指定为 Color?另外,我如何指定可组合项的类型?

这些都不起作用

const props = defineProps({
  selected: {
    /** @type {Color} */
    type: Object,
    required: true,
  },
  composable: {
    /** @type {function(): number} */
    type: Function,
    required: true
  }
})
Run Code Online (Sandbox Code Playgroud)
const props = defineProps({
  selected: {
    /** @type {{ new(): Color}} */ …
Run Code Online (Sandbox Code Playgroud)

jsdoc vue.js vuejs3 vue-composition-api

3
推荐指数
1
解决办法
1051
查看次数

标签 统计

jsdoc ×1

vue-composition-api ×1

vue.js ×1

vuejs3 ×1