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;