This repository was archived by the owner on Dec 25, 2024. It is now read-only.
File tree 3 files changed +45
-5
lines changed
3 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -67,13 +67,10 @@ export function getIdentifierUsages(node?: Expression | TSType | SpreadElement |
67
67
else if ( node . type === 'Identifier' ) {
68
68
identifiers . add ( node . name )
69
69
}
70
- else if ( node . type === 'MemberExpression' ) {
70
+ else if ( node . type === 'MemberExpression' || node . type === 'OptionalMemberExpression' ) {
71
71
getIdentifierUsages ( node . object , identifiers )
72
72
}
73
- else if ( node . type === 'OptionalMemberExpression' ) {
74
- getIdentifierUsages ( node . object , identifiers )
75
- }
76
- else if ( node . type === 'CallExpression' ) {
73
+ else if ( node . type === 'CallExpression' || node . type === 'OptionalCallExpression' ) {
77
74
getIdentifierUsages ( node . callee as Expression , identifiers )
78
75
node . arguments . forEach ( arg => getIdentifierUsages ( arg as Expression , identifiers ) )
79
76
}
Original file line number Diff line number Diff line change @@ -702,6 +702,35 @@ export default __sfc_main;
702
702
"
703
703
`;
704
704
705
+ exports[`transform fixtures test/fixtures/TemplateOptionalChaining.vue 1`] = `
706
+ " <template>
707
+ <div @click=\\"callback?.()\\">
708
+ { { text?.length ?? textLengthDefault }}
709
+ { { classes?.[0] }}
710
+ </div>
711
+ </template>
712
+
713
+ <script lang =\\"ts\\">
714
+ const __sfc_main = { } ;
715
+
716
+ __sfc_main.setup = (__props, __ctx) => {
717
+ const text = ' hello' ;
718
+ const textLengthDefault = 0 ;
719
+ const callback = (undefined as undefined | (() => void ));
720
+ const classes = (undefined as undefined | string []);
721
+ return {
722
+ text ,
723
+ textLengthDefault ,
724
+ callback ,
725
+ classes
726
+ };
727
+ } ;
728
+
729
+ export default __sfc_main;
730
+ </script>
731
+ "
732
+ `;
733
+
705
734
exports[`transform fixtures test/fixtures/VFor.vue 1`] = `
706
735
" <template>
707
736
<div>
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div @click =" callback?.()" >
3
+ {{ text?.length ?? textLengthDefault }}
4
+ {{ classes?.[0] }}
5
+ </div >
6
+ </template >
7
+
8
+ <script setup lang="ts">
9
+ const text = ' hello'
10
+ const textLengthDefault = 0
11
+
12
+ const callback = undefined as undefined | (() => void )
13
+ const classes = undefined as undefined | string []
14
+ </script >
You can’t perform that action at this time.
0 commit comments