From 1ee182bc3e9af0989d8569897348ce1a8972b88b Mon Sep 17 00:00:00 2001 From: lsdsjy Date: Fri, 1 Jul 2022 15:14:36 +0800 Subject: [PATCH] fix: strip strings before type cast detection --- packages/compiler-sfc/src/compileScript.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index d4b02663d06..9610c2a7383 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -1835,7 +1835,8 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) { const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/ function processExp(exp: string, dir?: string): string { - if (/ as\s+\w|<.*>|:/.test(exp)) { + const stringStripped = stripStrings(exp) + if (/ as\s+\w|<.*>|:/.test(stringStripped)) { if (dir === 'slot') { exp = `(${exp})=>{}` } else if (dir === 'for') { @@ -1853,7 +1854,7 @@ function processExp(exp: string, dir?: string): string { }) return ret } - return stripStrings(exp) + return stringStripped } function stripStrings(exp: string) {