BundlerMinifier
BundlerMinifier copied to clipboard
Lexical declaration cannot appear in a single-statement context
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")
}
I got the same issue with node 11
Tools
- Microsoft Visual Studio Community 2019 v 16.6.5
- Bundler & Minifier v 2.8.396
Same issue as described by @WagnerExpansiva in #382
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?