From aa59e01f25a14e68aedac3d70b266218dbdbfef6 Mon Sep 17 00:00:00 2001 From: Vaibhav Rai Date: Wed, 12 Oct 2022 23:48:57 +0530 Subject: [PATCH] Refactor --- src/compiler/compile/Component.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 1ffd8a32c67d..795ae9906ab0 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -25,7 +25,7 @@ import TemplateScope from './nodes/shared/TemplateScope'; import fuzzymatch from '../utils/fuzzymatch'; import get_object from './utils/get_object'; import Slot from './nodes/Slot'; -import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, ExpressionStatement, AssignmentExpression, Literal, Property, RestElement, ExportDefaultDeclaration, ExportAllDeclaration, FunctionDeclaration, FunctionExpression } from 'estree'; +import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, ExpressionStatement, AssignmentExpression, Literal, Property, RestElement, ExportDefaultDeclaration, ExportAllDeclaration, FunctionDeclaration, FunctionExpression, VariableDeclarator } from 'estree'; import add_to_set from './utils/add_to_set'; import check_graph_for_cycles from './utils/check_graph_for_cycles'; import { print, b } from 'code-red'; @@ -1309,12 +1309,12 @@ export default class Component { walk(node.body, { enter(node: Node, parent) { if (node.type === 'VariableDeclaration' && node.kind === 'var') { - const names = extract_names(node.declarations[0].id); - const is_var_in_outset = names.every((i: string) => { - if (outset_scope_decalarations.has(i)) { - const varNode = outset_scope_decalarations.get(i); - return varNode === node; - } + const is_var_in_outset = node.declarations.some((declaration: VariableDeclarator) => { + const names: string[] = extract_names(declaration.id); + return !!names.find((name: string) => { + const var_node = outset_scope_decalarations.get(name); + return var_node === node; + }); }); if (is_var_in_outset) { return component.error(node as any, compiler_errors.invalid_var_declaration);