Skip to content

Commit

Permalink
addressed PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vladima committed Mar 17, 2016
1 parent 6cf57b1 commit c9ef8be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("(");
}

Expand Down

0 comments on commit c9ef8be

Please sign in to comment.