From 77e26cd54947242b6b994cd24e4ff476422edeb9 Mon Sep 17 00:00:00 2001 From: TyrealHu Date: Wed, 18 Oct 2023 10:05:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=8C=9Fset=20jsx=20options=20t?= =?UTF-8?q?o=20true,=20while=20its=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/utils.ts | 6 +----- src/extentions/jsx/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/__test__/utils.ts b/__test__/utils.ts index 2fc0ac7..6d97497 100644 --- a/__test__/utils.ts +++ b/__test__/utils.ts @@ -1,11 +1,7 @@ import * as acorn from 'acorn' import tsPlugin from '../src' -export const Parser = acorn.Parser.extend(tsPlugin({ - jsx: { - allowNamespaces: true - } -})) +export const Parser = acorn.Parser.extend(tsPlugin()) export const DtsParser = acorn.Parser.extend(tsPlugin({ dts: true diff --git a/src/extentions/jsx/index.ts b/src/extentions/jsx/index.ts index f88f436..04de4da 100644 --- a/src/extentions/jsx/index.ts +++ b/src/extentions/jsx/index.ts @@ -44,10 +44,10 @@ export default function generateJsxParser( const tok = acornTypeScript.tokTypes const isNewLine = acorn.isNewLine const isIdentifierChar = acorn.isIdentifierChar - const options = { - allowNamespaces: (Boolean(jsxOptions?.allowNamespaces)) !== false, - allowNamespacedObjects: !!(jsxOptions?.allowNamespacedObjects) - } + const options = Object.assign({ + allowNamespaces: true, + allowNamespacedObjects: true + }, jsxOptions || {}) return class JsxParser extends Parser { // Reads inline JSX contents token.