diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index afd727b6f92..e7ea6cd1fcb 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3189,7 +3189,6 @@ namespace ts { let transformFlags = subtreeFlags; const expression = node.expression; const expressionKind = expression.kind; - const expressionTransformFlags = expression.transformFlags; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them @@ -3199,12 +3198,6 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript; } - // If the expression of a ParenthesizedExpression is a destructuring assignment, - // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & TransformFlags.DestructuringAssignment) { - transformFlags |= TransformFlags.DestructuringAssignment; - } - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; return transformFlags & ~TransformFlags.OuterExpressionExcludes; } @@ -3585,15 +3578,7 @@ namespace ts { } function computeExpressionStatement(node: ExpressionStatement, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - - // If the expression of an expression statement is a destructuring assignment, - // then we treat the statement as ES6 so that we can indicate that we do not - // need to hold on to the right-hand side. - if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) { - transformFlags |= TransformFlags.AssertES2015; - } - + const transformFlags = subtreeFlags; node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; return transformFlags & ~TransformFlags.NodeExcludes; } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 91d9349d52a..97cc1d5b062 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -316,7 +316,7 @@ namespace ts { else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & TransformFlags.Generator) { + else if (isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } else if (transformFlags & TransformFlags.ContainsGenerator) { diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 5c68da23821..621012ebc3b 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -537,8 +537,8 @@ namespace ts { if (isImportCall(node)) { return visitImportCallExpression(node); } - else if (node.transformFlags & TransformFlags.DestructuringAssignment && isBinaryExpression(node)) { - return visitDestructuringAssignment(node as DestructuringAssignment); + else if (isDestructuringAssignment(node)) { + return visitDestructuringAssignment(node); } else { return visitEachChild(node, moduleExpressionElementVisitor, context); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index a25e8c31c4a..ae303440bc1 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1463,9 +1463,8 @@ namespace ts { * @param node The node to visit. */ function destructuringAndImportCallVisitor(node: Node): VisitResult { - if (node.transformFlags & TransformFlags.DestructuringAssignment - && node.kind === SyntaxKind.BinaryExpression) { - return visitDestructuringAssignment(node); + if (isDestructuringAssignment(node)) { + return visitDestructuringAssignment(node); } else if (isImportCall(node)) { return visitImportCallExpression(node); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d89502a55f8..0ec0dec85e9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5049,21 +5049,20 @@ namespace ts { ContainsES2016 = 1 << 5, ContainsES2015 = 1 << 6, ContainsGenerator = 1 << 7, - DestructuringAssignment = 1 << 8, - ContainsDestructuringAssignment = 1 << 9, + ContainsDestructuringAssignment = 1 << 8, // Markers // - Flags used to indicate that a subtree contains a specific transformation. - ContainsTypeScriptClassSyntax = 1 << 10, // Decorators, Property Initializers, Parameter Property Initializers - ContainsLexicalThis = 1 << 11, - ContainsRestOrSpread = 1 << 12, - ContainsObjectRestOrSpread = 1 << 13, - ContainsComputedPropertyName = 1 << 14, - ContainsBlockScopedBinding = 1 << 15, - ContainsBindingPattern = 1 << 16, - ContainsYield = 1 << 17, - ContainsHoistedDeclarationOrCompletion = 1 << 18, - ContainsDynamicImport = 1 << 19, + ContainsTypeScriptClassSyntax = 1 << 9, // Decorators, Property Initializers, Parameter Property Initializers + ContainsLexicalThis = 1 << 10, + ContainsRestOrSpread = 1 << 11, + ContainsObjectRestOrSpread = 1 << 12, + ContainsComputedPropertyName = 1 << 13, + ContainsBlockScopedBinding = 1 << 14, + ContainsBindingPattern = 1 << 15, + ContainsYield = 1 << 16, + ContainsHoistedDeclarationOrCompletion = 1 << 17, + ContainsDynamicImport = 1 << 18, // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. @@ -5080,12 +5079,12 @@ namespace ts { AssertES2016 = ContainsES2016, AssertES2015 = ContainsES2015, AssertGenerator = ContainsGenerator, - AssertDestructuringAssignment = DestructuringAssignment | ContainsDestructuringAssignment, + AssertDestructuringAssignment = ContainsDestructuringAssignment, // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - OuterExpressionExcludes = DestructuringAssignment | HasComputedFlags, + OuterExpressionExcludes = HasComputedFlags, PropertyAccessExcludes = OuterExpressionExcludes, NodeExcludes = PropertyAccessExcludes, ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,