diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 78e83c148e6..5972e4c69eb 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4221,15 +4221,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const isExported = getCombinedNodeFlags(node) & NodeFlags.Export; if (languageVersion >= ScriptTarget.ES6 && (!isExported || modulekind === ModuleKind.ES6)) { // emit ES6 destructuring only if target module is ES6 or variable is not exported - // exported variables in CJS\AMD are prefixed with 'exports.' so result javascript { exports.toString } = 1; is illegal + // exported variables in CJS/AMD are prefixed with 'exports.' so result javascript { exports.toString } = 1; is illegal const isTopLevelDeclarationInSystemModule = modulekind === ModuleKind.System && shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/true); if (isTopLevelDeclarationInSystemModule) { - // in System modules top level variables are hoisted - // so variable declarations with destructuring are turned into destructuring assignments + // In System modules top level variables are hoisted + // so variable declarations with destructuring are turned into destructuring assignments. + // As a result, they will need parentheses to disambiguate object binding assignments from blocks. write("("); }