@@ -426,24 +426,32 @@ module.exports = {
426
426
* @returns {boolean }
427
427
*/
428
428
isVueComponent ( node ) {
429
- const callee = node . callee
429
+ if ( node . type === 'CallExpression' ) {
430
+ const callee = node . callee
430
431
431
- const isFullVueComponent = node . type === 'CallExpression' &&
432
- callee . type === 'MemberExpression' &&
433
- callee . object . type === 'Identifier' &&
434
- callee . object . name === 'Vue' &&
435
- callee . property . type === 'Identifier' &&
436
- [ 'component' , 'mixin' , 'extend' ] . indexOf ( callee . property . name ) > - 1 &&
437
- node . arguments . length >= 1 &&
438
- node . arguments . slice ( - 1 ) [ 0 ] . type === 'ObjectExpression'
432
+ if ( callee . type === 'MemberExpression' ) {
433
+ const calleeObject = this . unwrapTypes ( callee . object )
439
434
440
- const isDestructedVueComponent = node . type === 'CallExpression' &&
441
- callee . type === 'Identifier' &&
442
- callee . name === 'component' &&
443
- node . arguments . length >= 1 &&
444
- node . arguments . slice ( - 1 ) [ 0 ] . type === 'ObjectExpression'
435
+ const isFullVueComponent = calleeObject . type === 'Identifier' &&
436
+ calleeObject . name === 'Vue' &&
437
+ callee . property . type === 'Identifier' &&
438
+ [ 'component' , 'mixin' , 'extend' ] . indexOf ( callee . property . name ) > - 1 &&
439
+ node . arguments . length >= 1 &&
440
+ node . arguments . slice ( - 1 ) [ 0 ] . type === 'ObjectExpression'
441
+
442
+ return isFullVueComponent
443
+ }
445
444
446
- return isFullVueComponent || isDestructedVueComponent
445
+ if ( callee . type === 'Identifier' ) {
446
+ const isDestructedVueComponent = callee . name === 'component' &&
447
+ node . arguments . length >= 1 &&
448
+ node . arguments . slice ( - 1 ) [ 0 ] . type === 'ObjectExpression'
449
+
450
+ return isDestructedVueComponent
451
+ }
452
+ }
453
+
454
+ return false
447
455
} ,
448
456
449
457
/**
@@ -671,7 +679,7 @@ module.exports = {
671
679
/**
672
680
* Parse CallExpression or MemberExpression to get simplified version without arguments
673
681
*
674
- * @param {Object } node The node to parse (MemberExpression | CallExpression)
682
+ * @param {ASTNode } node The node to parse (MemberExpression | CallExpression)
675
683
* @return {String } eg. 'this.asd.qwe().map().filter().test.reduce()'
676
684
*/
677
685
parseMemberOrCallExpression ( node ) {
@@ -703,5 +711,14 @@ module.exports = {
703
711
}
704
712
705
713
return parsedCallee . reverse ( ) . join ( '.' ) . replace ( / \. \[ / g, '[' )
714
+ } ,
715
+
716
+ /**
717
+ * Unwrap typescript types like "X as F"
718
+ * @param {ASTNode } node
719
+ * @return {ASTNode }
720
+ */
721
+ unwrapTypes ( node ) {
722
+ return node . type === 'TSAsExpression' ? node . expression : node
706
723
}
707
724
}
0 commit comments