diff --git a/src/core/identifiers.ts b/src/core/identifiers.ts index 919fe0d..cd8ddc7 100644 --- a/src/core/identifiers.ts +++ b/src/core/identifiers.ts @@ -67,13 +67,10 @@ export function getIdentifierUsages(node?: Expression | TSType | SpreadElement | else if (node.type === 'Identifier') { identifiers.add(node.name) } - else if (node.type === 'MemberExpression') { + else if (node.type === 'MemberExpression' || node.type === 'OptionalMemberExpression') { getIdentifierUsages(node.object, identifiers) } - else if (node.type === 'OptionalMemberExpression') { - getIdentifierUsages(node.object, identifiers) - } - else if (node.type === 'CallExpression') { + else if (node.type === 'CallExpression' || node.type === 'OptionalCallExpression') { getIdentifierUsages(node.callee as Expression, identifiers) node.arguments.forEach(arg => getIdentifierUsages(arg as Expression, identifiers)) } diff --git a/test/__snapshots__/transform.test.ts.snap b/test/__snapshots__/transform.test.ts.snap index 9a03518..79e7481 100644 --- a/test/__snapshots__/transform.test.ts.snap +++ b/test/__snapshots__/transform.test.ts.snap @@ -702,6 +702,35 @@ export default __sfc_main; " `; +exports[`transform fixtures test/fixtures/TemplateOptionalChaining.vue 1`] = ` +" + + +" +`; + exports[`transform fixtures test/fixtures/VFor.vue 1`] = ` "