Vue 2.7.10 composition api - defineExpose overrides everything
Summary
Using vuedoc/parser ^4.0.0-beta12
My component library is using vuedocs/parser to create component documentation. I know it's probably not made with vue 2.x in mind, but it works really well so please forgive me if this is a vue 2 issue.
I have a set of functions that should be callable by other components. (an extension of v-form from vuetify). At the bottom of my component-file I have a defineExpose function that exposes these functions:
defineExpose({ resetValidation, reset, validate, getFormName, getInputSettings, getGroupSettings, customizableInputClicked, customizableGroupClicked, });
The json that is returned by the parser no longer has any props / events.
{
"name": "GatFormB",
"inheritAttrs": true,
"errors": [],
"warnings": [],
"keywords": [],
"props": [],
"data": [
{
"kind": "data",
"keywords": [],
"visibility": "public",
"name": "props",
"type": "unknown",
"initialValue": "withDefaults(defineProps<Props>(), {\r\n value: undefined,\r\n loading: false,\r\n readOnly: false,\r\n disabled: false,\r\n overlayZIndex: 901,\r\n noMaxWidth: false,\r\n inputSettings: () => [],\r\n groupSettings: () => [],\r\n})"
}
],
"computed": [],
"methods": [
{
"kind": "method",
"keywords": [],
"visibility": "public",
"name": "resetValidation",
"params": [],
"syntax": [
"resetValidation(): void"
],
"returns": {
"type": "void"
}
},
{
"kind": "method",
"keywords": [],
"visibility": "public",
"name": "reset",
"params": [],
"syntax": [
"reset(): void"
],
"returns": {
"type": "void"
}
},
{
"kind": "method",
"keywords": [],
"visibility": "public",
"name": "validate",
"params": [
{
"name": "showWarning",
"type": "boolean",
"rest": false,
"defaultValue": "true"
}
],
"syntax": [
"validate(showWarning: boolean = true): boolean"
],
"returns": {
"type": "boolean"
}
},
{
"kind": "method",
"description": "Function that will be called by a input.",
"keywords": [],
"visibility": "public",
"name": "getFormName",
"params": [],
"syntax": [
"getFormName(): string | undefined"
],
"returns": {
"type": "string | undefined"
}
},
{
"kind": "method",
"description": "Function that will be called by a input.",
"keywords": [],
"visibility": "public",
"name": "getInputSettings",
"params": [],
"syntax": [
"getInputSettings(): CustomizableInputSettings[]"
],
"returns": {
"type": "CustomizableInputSettings[]"
}
},
{
"kind": "method",
"description": "Function that will be called by a group",
"keywords": [],
"visibility": "public",
"name": "getGroupSettings",
"params": [],
"syntax": [
"getGroupSettings(): CustomizableGroupSetting[]"
],
"returns": {
"type": "CustomizableGroupSetting[]"
}
},
{
"kind": "method",
"description": "Function that will be called by a input.",
"keywords": [],
"visibility": "public",
"name": "customizableInputClicked",
"params": [
{
"name": "val",
"type": "any",
"rest": false
}
],
"syntax": [
"customizableInputClicked(val: any): void"
],
"returns": {
"type": "void"
}
},
{
"kind": "method",
"description": "Function that will be called by a input.",
"keywords": [],
"visibility": "public",
"name": "customizableGroupClicked",
"params": [
{
"name": "val",
"type": "any",
"rest": false
}
],
"syntax": [
"customizableGroupClicked(val: any): void"
],
"returns": {
"type": "void"
}
}
],
"events": [],
"slots": [
{
"kind": "slot",
"description": "The default Vue slot.",
"keywords": [],
"visibility": "public",
"name": "default",
"props": []
}
]
}
If I remove the defineExpose function I get my props / events back. I have not tested this with vue 3.
Steps to reproduce
- Create a new .vue file using composition api. I use the script setup syntax.
- Add some props, events, functions, slots etc.
- Generate JSON file. Should work as expected, the json file now has the entries it should have.
- Expose some function with defineExpose(). Only the exposed methods etc are generated by the parser.
Example Project
Sorry, I can make one at a later point.
What is the current bug behavior?
I don't get the expected result from the file parser.
What is the expected correct behavior?
I should get the same result while using defineExpose.
Possible fixes
N/A