From 740193b1e2d5397c661ea3cd1f0b8445308461ab Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 14 Nov 2014 09:14:49 +1100 Subject: [PATCH] fix up types.toStatement and return an expressionStatement if all else fails --- lib/6to5/types/index.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index c921215e4f..34371d3999 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -119,18 +119,12 @@ t.toStatement = function (node, ignore) { } else if (t.isFunction(node)) { mustHaveId = true; newType = "FunctionDeclaration"; + } else { + return t.expressionStatement(node); } if (mustHaveId && !node.id) { - newType = false; - } - - if (!newType) { - if (ignore) { - return false; - } else { - throw new Error("cannot turn " + node.type + " to a statement"); - } + throw new Error("the type " + node.type + " needs an id in order to be transformed into a statement"); } node.type = newType;