From 01e8ba8f873afe3857a23fb68b44fdc057e31781 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 25 May 2021 00:13:37 +0800 Subject: [PATCH] fix(compiler-sfc): support tsx in setup script (#3825) close #3808 --- packages/compiler-sfc/src/compileScript.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 5bb8a246..10912838 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -101,7 +101,11 @@ export function compileScript( sfc.template && sfc.template.attrs['inherit-attrs'] === 'false' const scriptLang = script && script.lang const scriptSetupLang = scriptSetup && scriptSetup.lang - const isTS = scriptLang === 'ts' || scriptSetupLang === 'ts' + const isTS = + scriptLang === 'ts' || + scriptLang === 'tsx' || + scriptSetupLang === 'ts' || + scriptSetupLang === 'tsx' const plugins: ParserPlugin[] = [...babelParserDefaultPlugins, 'jsx'] if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins) if (isTS) plugins.push('typescript', 'decorators-legacy') @@ -110,7 +114,7 @@ export function compileScript( if (!script) { throw new Error(`[@vue/compiler-sfc] SFC contains no