This repository was archived by the owner on Dec 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +45
-5
lines changed Expand file tree Collapse file tree 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 |
6767 else if ( node . type === 'Identifier' ) {
6868 identifiers . add ( node . name )
6969 }
70- else if ( node . type === 'MemberExpression' ) {
70+ else if ( node . type === 'MemberExpression' || node . type === 'OptionalMemberExpression' ) {
7171 getIdentifierUsages ( node . object , identifiers )
7272 }
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' ) {
7774 getIdentifierUsages ( node . callee as Expression , identifiers )
7875 node . arguments . forEach ( arg => getIdentifierUsages ( arg as Expression , identifiers ) )
7976 }
Original file line number Diff line number Diff line change @@ -702,6 +702,35 @@ export default __sfc_main;
702702"
703703`;
704704
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+
705734exports[`transform fixtures test/fixtures/VFor.vue 1`] = `
706735" <template>
707736 <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