From: Jason Date: Mon, 24 May 2021 16:13:37 +0000 (+0800) Subject: fix(compiler-sfc): support tsx in setup script (#3825) X-Git-Tag: v3.1.0-beta.4~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01e8ba8f873afe3857a23fb68b44fdc057e31781;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): support tsx in setup script (#3825) close #3808 --- diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 5bb8a2461a..10912838e5 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