BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Lexical declaration cannot appear in a single-statement context

Open WagnerExpansiva opened this issue 6 years ago • 3 comments

Installed product versions

  • Visual Studio: Community 2017 v 15.8.1
  • This extension: 2.8.391

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")
}

WagnerExpansiva avatar Sep 15 '18 21:09 WagnerExpansiva

I got the same issue with node 11

SalathielGenese avatar Feb 11 '19 16:02 SalathielGenese

Tools

  • Microsoft Visual Studio Community 2019 v 16.6.5
  • Bundler & Minifier v 2.8.396

Same issue as described by @WagnerExpansiva in #382

a4armaan avatar Aug 10 '20 07:08 a4armaan

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?

washamdev avatar May 05 '23 02:05 washamdev