diff --git a/packages/compiler-sfc/__tests__/compileScript.spec.ts b/packages/compiler-sfc/__tests__/compileScript.spec.ts index afe656b4a2c..6da274dd8a5 100644 --- a/packages/compiler-sfc/__tests__/compileScript.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript.spec.ts @@ -804,6 +804,25 @@ describe('SFC compile + + `, + { + inlineTemplate: false + } + ) + ).not.toThrowError() + }) }) describe('with TypeScript', () => { diff --git a/packages/compiler-sfc/src/script/importUsageCheck.ts b/packages/compiler-sfc/src/script/importUsageCheck.ts index 59473a9dda3..b42397d573b 100644 --- a/packages/compiler-sfc/src/script/importUsageCheck.ts +++ b/packages/compiler-sfc/src/script/importUsageCheck.ts @@ -83,7 +83,9 @@ function processExp(exp: string, dir?: string): string { } else if (dir === 'for') { const inMatch = exp.match(forAliasRE) if (inMatch) { - const [, LHS, RHS] = inMatch + let [, LHS, RHS] = inMatch + // #6088 + LHS = LHS.trim().replace(/^\(|\)$/g, '') return processExp(`(${LHS})=>{}`) + processExp(RHS) } }