Skip to content

Commit 1f212ec

Browse files
committed
Remove DestructuringAssignment and Generator flags
1 parent cc9e2f4 commit 1f212ec

File tree

5 files changed

+19
-36
lines changed

5 files changed

+19
-36
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,7 +3189,6 @@ namespace ts {
31893189
let transformFlags = subtreeFlags;
31903190
const expression = node.expression;
31913191
const expressionKind = expression.kind;
3192-
const expressionTransformFlags = expression.transformFlags;
31933192

31943193
// If the node is synthesized, it means the emitter put the parentheses there,
31953194
// not the user. If we didn't want them, the emitter would not have put them
@@ -3199,12 +3198,6 @@ namespace ts {
31993198
transformFlags |= TransformFlags.AssertTypeScript;
32003199
}
32013200

3202-
// If the expression of a ParenthesizedExpression is a destructuring assignment,
3203-
// then the ParenthesizedExpression is a destructuring assignment.
3204-
if (expressionTransformFlags & TransformFlags.DestructuringAssignment) {
3205-
transformFlags |= TransformFlags.DestructuringAssignment;
3206-
}
3207-
32083201
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
32093202
return transformFlags & ~TransformFlags.OuterExpressionExcludes;
32103203
}
@@ -3585,15 +3578,7 @@ namespace ts {
35853578
}
35863579

35873580
function computeExpressionStatement(node: ExpressionStatement, subtreeFlags: TransformFlags) {
3588-
let transformFlags = subtreeFlags;
3589-
3590-
// If the expression of an expression statement is a destructuring assignment,
3591-
// then we treat the statement as ES6 so that we can indicate that we do not
3592-
// need to hold on to the right-hand side.
3593-
if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) {
3594-
transformFlags |= TransformFlags.AssertES2015;
3595-
}
3596-
3581+
const transformFlags = subtreeFlags;
35973582
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
35983583
return transformFlags & ~TransformFlags.NodeExcludes;
35993584
}

src/compiler/transformers/generators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ namespace ts {
316316
else if (inGeneratorFunctionBody) {
317317
return visitJavaScriptInGeneratorFunctionBody(node);
318318
}
319-
else if (transformFlags & TransformFlags.Generator) {
319+
else if (isFunctionLikeDeclaration(node) && node.asteriskToken) {
320320
return visitGenerator(node);
321321
}
322322
else if (transformFlags & TransformFlags.ContainsGenerator) {

src/compiler/transformers/module/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ namespace ts {
537537
if (isImportCall(node)) {
538538
return visitImportCallExpression(node);
539539
}
540-
else if (node.transformFlags & TransformFlags.DestructuringAssignment && isBinaryExpression(node)) {
541-
return visitDestructuringAssignment(node as DestructuringAssignment);
540+
else if (isDestructuringAssignment(node)) {
541+
return visitDestructuringAssignment(node);
542542
}
543543
else {
544544
return visitEachChild(node, moduleExpressionElementVisitor, context);

src/compiler/transformers/module/system.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,9 +1463,8 @@ namespace ts {
14631463
* @param node The node to visit.
14641464
*/
14651465
function destructuringAndImportCallVisitor(node: Node): VisitResult<Node> {
1466-
if (node.transformFlags & TransformFlags.DestructuringAssignment
1467-
&& node.kind === SyntaxKind.BinaryExpression) {
1468-
return visitDestructuringAssignment(<DestructuringAssignment>node);
1466+
if (isDestructuringAssignment(node)) {
1467+
return visitDestructuringAssignment(node);
14691468
}
14701469
else if (isImportCall(node)) {
14711470
return visitImportCallExpression(node);

src/compiler/types.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5049,21 +5049,20 @@ namespace ts {
50495049
ContainsES2016 = 1 << 5,
50505050
ContainsES2015 = 1 << 6,
50515051
ContainsGenerator = 1 << 7,
5052-
DestructuringAssignment = 1 << 8,
5053-
ContainsDestructuringAssignment = 1 << 9,
5052+
ContainsDestructuringAssignment = 1 << 8,
50545053

50555054
// Markers
50565055
// - Flags used to indicate that a subtree contains a specific transformation.
5057-
ContainsTypeScriptClassSyntax = 1 << 10, // Decorators, Property Initializers, Parameter Property Initializers
5058-
ContainsLexicalThis = 1 << 11,
5059-
ContainsRestOrSpread = 1 << 12,
5060-
ContainsObjectRestOrSpread = 1 << 13,
5061-
ContainsComputedPropertyName = 1 << 14,
5062-
ContainsBlockScopedBinding = 1 << 15,
5063-
ContainsBindingPattern = 1 << 16,
5064-
ContainsYield = 1 << 17,
5065-
ContainsHoistedDeclarationOrCompletion = 1 << 18,
5066-
ContainsDynamicImport = 1 << 19,
5056+
ContainsTypeScriptClassSyntax = 1 << 9, // Decorators, Property Initializers, Parameter Property Initializers
5057+
ContainsLexicalThis = 1 << 10,
5058+
ContainsRestOrSpread = 1 << 11,
5059+
ContainsObjectRestOrSpread = 1 << 12,
5060+
ContainsComputedPropertyName = 1 << 13,
5061+
ContainsBlockScopedBinding = 1 << 14,
5062+
ContainsBindingPattern = 1 << 15,
5063+
ContainsYield = 1 << 16,
5064+
ContainsHoistedDeclarationOrCompletion = 1 << 17,
5065+
ContainsDynamicImport = 1 << 18,
50675066

50685067
// Please leave this as 1 << 29.
50695068
// 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 {
50805079
AssertES2016 = ContainsES2016,
50815080
AssertES2015 = ContainsES2015,
50825081
AssertGenerator = ContainsGenerator,
5083-
AssertDestructuringAssignment = DestructuringAssignment | ContainsDestructuringAssignment,
5082+
AssertDestructuringAssignment = ContainsDestructuringAssignment,
50845083

50855084
// Scope Exclusions
50865085
// - Bitmasks that exclude flags from propagating out of a specific context
50875086
// into the subtree flags of their container.
5088-
OuterExpressionExcludes = DestructuringAssignment | HasComputedFlags,
5087+
OuterExpressionExcludes = HasComputedFlags,
50895088
PropertyAccessExcludes = OuterExpressionExcludes,
50905089
NodeExcludes = PropertyAccessExcludes,
50915090
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,

0 commit comments

Comments
 (0)