Skip to content

Commit aa59e01

Browse files
committed
Refactor
1 parent dc82f0a commit aa59e01

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: src/compiler/compile/Component.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import TemplateScope from './nodes/shared/TemplateScope';
2525
import fuzzymatch from '../utils/fuzzymatch';
2626
import get_object from './utils/get_object';
2727
import Slot from './nodes/Slot';
28-
import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, ExpressionStatement, AssignmentExpression, Literal, Property, RestElement, ExportDefaultDeclaration, ExportAllDeclaration, FunctionDeclaration, FunctionExpression } from 'estree';
28+
import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, ExpressionStatement, AssignmentExpression, Literal, Property, RestElement, ExportDefaultDeclaration, ExportAllDeclaration, FunctionDeclaration, FunctionExpression, VariableDeclarator } from 'estree';
2929
import add_to_set from './utils/add_to_set';
3030
import check_graph_for_cycles from './utils/check_graph_for_cycles';
3131
import { print, b } from 'code-red';
@@ -1309,12 +1309,12 @@ export default class Component {
13091309
walk(node.body, {
13101310
enter(node: Node, parent) {
13111311
if (node.type === 'VariableDeclaration' && node.kind === 'var') {
1312-
const names = extract_names(node.declarations[0].id);
1313-
const is_var_in_outset = names.every((i: string) => {
1314-
if (outset_scope_decalarations.has(i)) {
1315-
const varNode = outset_scope_decalarations.get(i);
1316-
return varNode === node;
1317-
}
1312+
const is_var_in_outset = node.declarations.some((declaration: VariableDeclarator) => {
1313+
const names: string[] = extract_names(declaration.id);
1314+
return !!names.find((name: string) => {
1315+
const var_node = outset_scope_decalarations.get(name);
1316+
return var_node === node;
1317+
});
13181318
});
13191319
if (is_var_in_outset) {
13201320
return component.error(node as any, compiler_errors.invalid_var_declaration);

0 commit comments

Comments
 (0)