madskristensen / BundlerMinifier

Visual Studio extension
Other
616 stars 172 forks source link

Lexical declaration cannot appear in a single-statement context #382

Open WagnerExpansiva opened 6 years ago

WagnerExpansiva commented 6 years ago

Installed product versions

Description

When using let alone in scope, will get this error (in Chrome) "Uncaught SyntaxError: Lexical declaration cannot appear in a single-statement context"

For example, this code

function TestError() {
    if (true) {
        let k2 = new Object("ss");
    }
}

is being minified as:

function TestError()
{
  if (1)
    let k2 = new Object("ss")
}

so , try to past the above code in chrome / console, and will get the error

Expected behavior

function TestError()
{
  if (1)
    new Object("ss")
}
SalathielGenese commented 5 years ago

I got the same issue with node 11

a4armaan commented 4 years ago

Tools

Same issue as described by @WagnerExpansiva in #382

washamdev commented 1 year ago

This problem is still occurring in 2023. Did anyone ever find a fix for it? This only started happening when we changed our tsconfig.json file to "target": "ES6", so TypeScript started using let and const throughout our code, but now minification is broken because we are using this plugin. Are we going to have to switch minification plugins entirely?