@@ -1553,6 +1553,12 @@ module.exports = {
1553
1553
const left = getLeftOfDefineProps ( node )
1554
1554
return left ?. type === 'ObjectPattern'
1555
1555
} ,
1556
+ /**
1557
+ * Gets the props destructure property nodes for defineProp.
1558
+ * @param {CallExpression } node The node of defineProps
1559
+ * @returns { Record<string, AssignmentProperty | undefined> }
1560
+ */
1561
+ getPropsDestructure,
1556
1562
1557
1563
getVueObjectType,
1558
1564
/**
@@ -3161,30 +3167,45 @@ function getWithDefaultsProps(node) {
3161
3167
}
3162
3168
3163
3169
/**
3164
- * Gets the default definition nodes for defineProp
3165
- * using the props destructure with assignment pattern.
3170
+ * Gets the props destructure property nodes for defineProp.
3166
3171
* @param {CallExpression } node The node of defineProps
3167
- * @returns { Record<string, {prop: AssignmentProperty , expression: Expression} | undefined> }
3172
+ * @returns { Record<string, AssignmentProperty | undefined> }
3168
3173
*/
3169
- function getDefaultPropExpressionsForPropsDestructure ( node ) {
3174
+ function getPropsDestructure ( node ) {
3175
+ /** @type {ReturnType<typeof getPropsDestructure> } */
3176
+ const result = Object . create ( null )
3170
3177
const left = getLeftOfDefineProps ( node )
3171
3178
if ( ! left || left . type !== 'ObjectPattern' ) {
3172
- return { }
3179
+ return result
3173
3180
}
3174
- /** @type {ReturnType<typeof getDefaultPropExpressionsForPropsDestructure> } */
3175
- const result = Object . create ( null )
3176
3181
for ( const prop of left . properties ) {
3177
3182
if ( prop . type !== 'Property' ) continue
3178
- const value = prop . value
3179
- if ( value . type !== 'AssignmentPattern' ) continue
3180
3183
const name = getStaticPropertyName ( prop )
3181
3184
if ( name != null ) {
3182
- result [ name ] = { prop, expression : value . right }
3185
+ result [ name ] = prop
3183
3186
}
3184
3187
}
3185
3188
return result
3186
3189
}
3187
3190
3191
+ /**
3192
+ * Gets the default definition nodes for defineProp
3193
+ * using the props destructure with assignment pattern.
3194
+ * @param {CallExpression } node The node of defineProps
3195
+ * @returns { Record<string, {prop: AssignmentProperty , expression: Expression} | undefined> }
3196
+ */
3197
+ function getDefaultPropExpressionsForPropsDestructure ( node ) {
3198
+ /** @type {ReturnType<typeof getDefaultPropExpressionsForPropsDestructure> } */
3199
+ const result = Object . create ( null )
3200
+ for ( const [ name , prop ] of Object . entries ( getPropsDestructure ( node ) ) ) {
3201
+ if ( ! prop ) continue
3202
+ const value = prop . value
3203
+ if ( value . type !== 'AssignmentPattern' ) continue
3204
+ result [ name ] = { prop, expression : value . right }
3205
+ }
3206
+ return result
3207
+ }
3208
+
3188
3209
/**
3189
3210
* Gets the pattern of the left operand of defineProps.
3190
3211
* @param {CallExpression } node The node of defineProps
0 commit comments