Feature Request: Include default value for props
AbdallahAlhaddad opened this issue · comments
Feature description:
- Adding default values for props in the API response.
Demo Code:
type ClrVariants = 'primary' | 'secondary'
interface TooltipProps {
/**
* Color variant to choose from, see ...
*/
color?: ClrVariants
text: string
}
const { color = 'primary', text } = defineProps<TooltipProps>()
Api Response:
{
// ...
"meta": {
"props": [
{
"name": "text",
"global": false,
"description": "",
"tags": [],
"required": true,
"type": "string",
"declarations": [
{
"file": "nuxt-proj-absoulte-path/components/Tooltip.vue",
"range": [290, 302]
}
],
"schema": "string"
},
{
"name": "color",
"global": false,
"description": "Color variant to choose from, see ...",
"tags": [],
"required": false,
"default": "primary", // 👈 this field.
"type": "ClrVariants | undefined",
"declarations": [
{
"file": "nuxt-proj-absoulte-path/components/Tooltip.vue",
"range": [268, 287]
}
],
"schema": {
"kind": "enum",
"type": "ClrVariants | undefined",
"schema": ["undefined", "\"primary\"", "\"secondary\""]
}
}
]
// ...
}
}
If we use withDefaults
it will be determined correctly
const { color, text } = withDefaults(defineProps<TooltipProps>(), {
color: 'primary',
})