From 17f74b658547b25942f1cbf9ef2d0cb9657e4dd7 Mon Sep 17 00:00:00 2001 From: Kotaro Sugawara Date: Wed, 19 Jan 2022 18:31:42 +0900 Subject: [PATCH] fix(utils): fix propertyToJSXAttribute type error --- src/utils/propertyToJSXAttribute.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/propertyToJSXAttribute.ts b/src/utils/propertyToJSXAttribute.ts index 077bff0..605313e 100644 --- a/src/utils/propertyToJSXAttribute.ts +++ b/src/utils/propertyToJSXAttribute.ts @@ -3,8 +3,13 @@ import { AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -const getBaseNode = ({ loc, range }: TSESTree.Node): TSESTree.BaseNode => { +const getBaseNode = ({ + type, + loc, + range, +}: TSESTree.Node): TSESTree.BaseNode => { return { + type, loc, range, }; @@ -15,8 +20,10 @@ export const propertyToJSXAttribute = ( ): TSESTree.JSXAttribute => { const { key, value } = node; return { + ...getBaseNode(node), type: AST_NODE_TYPES.JSXAttribute, name: { + ...getBaseNode(key), type: AST_NODE_TYPES.JSXIdentifier, name: key.type === AST_NODE_TYPES.Identifier @@ -26,7 +33,6 @@ export const propertyToJSXAttribute = ( ? key.value : '' : '', - ...getBaseNode(key), }, value: value.type === AST_NODE_TYPES.AssignmentPattern || @@ -38,10 +44,9 @@ export const propertyToJSXAttribute = ( : value.type === AST_NODE_TYPES.Literal ? value : { + ...getBaseNode(value), type: AST_NODE_TYPES.JSXExpressionContainer, expression: value, - ...getBaseNode(value), }, - ...getBaseNode(node), }; };