From c08be3175ac26e675b8250754e2320cefd46dcdc Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Thu, 29 Jul 2021 12:24:25 +0900 Subject: [PATCH] Fix tsc error (#1583) --- .../no-use-computed-property-like-method.js | 19 ++++++++++--------- lib/utils/style-variables/index.js | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/rules/no-use-computed-property-like-method.js b/lib/rules/no-use-computed-property-like-method.js index 5b0371b8f..1add2c343 100644 --- a/lib/rules/no-use-computed-property-like-method.js +++ b/lib/rules/no-use-computed-property-like-method.js @@ -13,6 +13,7 @@ const utils = require('../utils') /** * @typedef {import('../utils').ComponentPropertyData} ComponentPropertyData * @typedef {import('../utils').ComponentObjectPropertyData} ComponentObjectPropertyData + * @typedef {import('../utils').GroupName} GroupName * * @typedef {{[key: string]: ComponentPropertyData & { valueType: { type: string | null } }}} PropertyMap */ @@ -167,7 +168,7 @@ const getValueType = ({ property, propertyMap }) => { } /** - * @param {Set} groups + * @param {Set} groups * @param {ObjectExpression} vueNodeMap * @param {PropertyMap} propertyMap */ @@ -198,18 +199,15 @@ module.exports = { }, /** @param {RuleContext} context */ create(context) { + /** @type {GroupName[]} */ const GROUP_NAMES = ['data', 'props', 'computed', 'methods'] const groups = new Set(GROUP_NAMES) - /** @type PropertyMap */ - const propertyMap = {} - - /**@type ObjectExpression */ - let vueNodeMap = {} + /** @type {PropertyMap} */ + const propertyMap = Object.create(null) return utils.defineVueVisitor(context, { onVueObjectEnter(node) { - vueNodeMap = node const properties = utils.iterateProperties(node, groups) for (const property of properties) { @@ -222,8 +220,11 @@ module.exports = { }, /** @param {ThisExpression} node */ - 'CallExpression > MemberExpression > ThisExpression'(node) { - addPropertyMap(groups, vueNodeMap, propertyMap) + 'CallExpression > MemberExpression > ThisExpression'( + node, + { node: vueNode } + ) { + addPropertyMap(groups, vueNode, propertyMap) if (node.parent.type !== 'MemberExpression') return if (node.parent.property.type !== 'Identifier') return diff --git a/lib/utils/style-variables/index.js b/lib/utils/style-variables/index.js index e2016a631..63caf208a 100644 --- a/lib/utils/style-variables/index.js +++ b/lib/utils/style-variables/index.js @@ -31,7 +31,7 @@ class StyleVariablesContext { } } -/** @type {Map} */ const cache = new Map() /** * Get the style vars context