@next-core/brick-utils 2.37.15 → 2.37.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -831,6 +831,7 @@ function collectBricksInCustomTemplates(customTemplates, collection, selfDefined
831
831
  customTemplates.forEach(tpl => {
832
832
  selfDefined.add(tpl.name);
833
833
  collectBricksInBrickConfs(tpl.bricks, collection);
834
+ collectBricksInContext(tpl.state, collection);
834
835
  });
835
836
  }
836
837
  }
@@ -3607,8 +3608,8 @@ var toUnenumerable = (object, key) => defineProperty(object, key, {
3607
3608
  });
3608
3609
 
3609
3610
  function toESTreeLocation(node) {
3610
- toUnenumerable(node.loc.start, "index");
3611
- toUnenumerable(node.loc.end, "index");
3611
+ node.loc.start && toUnenumerable(node.loc.start, "index");
3612
+ node.loc.end && toUnenumerable(node.loc.end, "index");
3612
3613
  return node;
3613
3614
  }
3614
3615
 
@@ -3882,10 +3883,9 @@ var estree = superClass => class extends superClass {
3882
3883
  }
3883
3884
 
3884
3885
  this.toAssignable(value, isLHS);
3885
- return node;
3886
+ } else {
3887
+ super.toAssignable(node, isLHS);
3886
3888
  }
3887
-
3888
- return super.toAssignable(node, isLHS);
3889
3889
  }
3890
3890
 
3891
3891
  toAssignableObjectExpressionProp(prop) {
@@ -3898,11 +3898,7 @@ var estree = superClass => class extends superClass {
3898
3898
  at: prop.key
3899
3899
  });
3900
3900
  } else {
3901
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
3902
- args[_key3 - 1] = arguments[_key3];
3903
- }
3904
-
3905
- super.toAssignableObjectExpressionProp(prop, ...args);
3901
+ super.toAssignableObjectExpressionProp(...arguments);
3906
3902
  }
3907
3903
  }
3908
3904
 
@@ -3999,6 +3995,11 @@ var estree = superClass => class extends superClass {
3999
3995
  return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
4000
3996
  }
4001
3997
 
3998
+ resetStartLocation(node, start, startLoc) {
3999
+ super.resetStartLocation(node, start, startLoc);
4000
+ toESTreeLocation(node);
4001
+ }
4002
+
4002
4003
  resetEndLocation(node) {
4003
4004
  var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
4004
4005
  super.resetEndLocation(node, endLoc);
@@ -4146,9 +4147,7 @@ var tt = {
4146
4147
  beforeExpr,
4147
4148
  startsExpr
4148
4149
  }),
4149
- braceR: createToken("}", {
4150
- beforeExpr
4151
- }),
4150
+ braceR: createToken("}"),
4152
4151
  braceBarR: createToken("|}"),
4153
4152
  parenL: createToken("(", {
4154
4153
  beforeExpr,
@@ -4573,6 +4572,10 @@ function tokenOperatorPrecedence(token) {
4573
4572
  return tokenBinops[token];
4574
4573
  }
4575
4574
 
4575
+ function tokenIsBinaryOperator(token) {
4576
+ return tokenBinops[token] !== -1;
4577
+ }
4578
+
4576
4579
  function tokenIsRightAssociative(token) {
4577
4580
  return token === 57;
4578
4581
  }
@@ -5038,6 +5041,7 @@ class State {
5038
5041
  this.hasFlowComment = false;
5039
5042
  this.isAmbientContext = false;
5040
5043
  this.inAbstractClass = false;
5044
+ this.inDisallowConditionalTypesContext = false;
5041
5045
  this.topicContext = {
5042
5046
  maxNumOfResolvableTopics: 0,
5043
5047
  maxTopicIndex: null
@@ -7050,7 +7054,7 @@ class ExpressionScopeHandler {
7050
7054
  this.parser.raise(toParseError, origin);
7051
7055
  }
7052
7056
 
7053
- recordParenthesizedIdentifierError(_ref45) {
7057
+ recordArrowParemeterBindingError(error, _ref45) {
7054
7058
  var {
7055
7059
  at: node
7056
7060
  } = _ref45;
@@ -7063,9 +7067,9 @@ class ExpressionScopeHandler {
7063
7067
  };
7064
7068
 
7065
7069
  if (scope.isCertainlyParameterDeclaration()) {
7066
- this.parser.raise(Errors.InvalidParenthesizedAssignment, origin);
7070
+ this.parser.raise(error, origin);
7067
7071
  } else if (scope.canBeArrowParameterDeclaration()) {
7068
- scope.recordDeclarationError(Errors.InvalidParenthesizedAssignment, origin);
7072
+ scope.recordDeclarationError(error, origin);
7069
7073
  } else {
7070
7074
  return;
7071
7075
  }
@@ -9516,11 +9520,11 @@ var flow = superClass => class extends superClass {
9516
9520
  toAssignable(node) {
9517
9521
  var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9518
9522
 
9519
- if (node.type === "TypeCastExpression") {
9520
- return super.toAssignable(this.typeCastToParameter(node), isLHS);
9521
- } else {
9522
- return super.toAssignable(node, isLHS);
9523
+ if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
9524
+ node.left = this.typeCastToParameter(node.left);
9523
9525
  }
9526
+
9527
+ super.toAssignable(...arguments);
9524
9528
  }
9525
9529
 
9526
9530
  toAssignableList(exprList, trailingCommaLoc, isLHS) {
@@ -9532,7 +9536,7 @@ var flow = superClass => class extends superClass {
9532
9536
  }
9533
9537
  }
9534
9538
 
9535
- return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
9539
+ super.toAssignableList(exprList, trailingCommaLoc, isLHS);
9536
9540
  }
9537
9541
 
9538
9542
  toReferencedList(exprList, isParenthesizedExpr) {
@@ -9562,8 +9566,8 @@ var flow = superClass => class extends superClass {
9562
9566
  }
9563
9567
 
9564
9568
  isValidLVal(type) {
9565
- for (var _len4 = arguments.length, rest = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
9566
- rest[_key4 - 1] = arguments[_key4];
9569
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
9570
+ rest[_key3 - 1] = arguments[_key3];
9567
9571
  }
9568
9572
 
9569
9573
  return type === "TypeCastExpression" || super.isValidLVal(type, ...rest);
@@ -10112,7 +10116,8 @@ var flow = superClass => class extends superClass {
10112
10116
  return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState);
10113
10117
  }
10114
10118
 
10115
- parseNewArguments(node) {
10119
+ parseNewCallee(node) {
10120
+ super.parseNewCallee(node);
10116
10121
  var targs = null;
10117
10122
 
10118
10123
  if (this.shouldParseTypes() && this.match(47)) {
@@ -10120,7 +10125,6 @@ var flow = superClass => class extends superClass {
10120
10125
  }
10121
10126
 
10122
10127
  node.typeArguments = targs;
10123
- super.parseNewArguments(node);
10124
10128
  }
10125
10129
 
10126
10130
  parseAsyncArrowWithTypeParameters(startPos, startLoc) {
@@ -11193,6 +11197,7 @@ var jsx = superClass => class extends superClass {
11193
11197
  this.next();
11194
11198
  node.expression = this.parseExpression();
11195
11199
  this.setContext(types.j_oTag);
11200
+ this.state.canStartJSXElement = true;
11196
11201
  this.expect(8);
11197
11202
  return this.finishNode(node, "JSXSpreadChild");
11198
11203
  }
@@ -11206,6 +11211,7 @@ var jsx = superClass => class extends superClass {
11206
11211
  }
11207
11212
 
11208
11213
  this.setContext(previousContext);
11214
+ this.state.canStartJSXElement = true;
11209
11215
  this.expect(8);
11210
11216
  return this.finishNode(node, "JSXExpressionContainer");
11211
11217
  }
@@ -11219,6 +11225,7 @@ var jsx = superClass => class extends superClass {
11219
11225
  this.expect(21);
11220
11226
  node.argument = this.parseMaybeAssignAllowIn();
11221
11227
  this.setContext(types.j_oTag);
11228
+ this.state.canStartJSXElement = true;
11222
11229
  this.expect(8);
11223
11230
  return this.finishNode(node, "JSXSpreadAttribute");
11224
11231
  }
@@ -11231,8 +11238,7 @@ var jsx = superClass => class extends superClass {
11231
11238
  jsxParseOpeningElementAt(startPos, startLoc) {
11232
11239
  var node = this.startNodeAt(startPos, startLoc);
11233
11240
 
11234
- if (this.match(139)) {
11235
- this.expect(139);
11241
+ if (this.eat(139)) {
11236
11242
  return this.finishNode(node, "JSXOpeningFragment");
11237
11243
  }
11238
11244
 
@@ -11256,8 +11262,7 @@ var jsx = superClass => class extends superClass {
11256
11262
  jsxParseClosingElementAt(startPos, startLoc) {
11257
11263
  var node = this.startNodeAt(startPos, startLoc);
11258
11264
 
11259
- if (this.match(139)) {
11260
- this.expect(139);
11265
+ if (this.eat(139)) {
11261
11266
  return this.finishNode(node, "JSXClosingFragment");
11262
11267
  }
11263
11268
 
@@ -11538,6 +11543,10 @@ function assert(x) {
11538
11543
  }
11539
11544
  }
11540
11545
 
11546
+ function tsTokenCanStartExpression(token) {
11547
+ return tokenCanStartExpression(token) || tokenIsBinaryOperator(token);
11548
+ }
11549
+
11541
11550
  var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["typescript"])))(_ => ({
11542
11551
  AbstractMethodHasImplementation: _(_ref71 => {
11543
11552
  var {
@@ -11613,10 +11622,22 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11613
11622
  } = _ref80;
11614
11623
  return "'".concat(modifier, "' modifier cannot appear on a type member.");
11615
11624
  }),
11616
- InvalidModifiersOrder: _(_ref81 => {
11625
+ InvalidModifierOnTypeParameter: _(_ref81 => {
11617
11626
  var {
11618
- orderedModifiers
11627
+ modifier
11619
11628
  } = _ref81;
11629
+ return "'".concat(modifier, "' modifier cannot appear on a type parameter.");
11630
+ }),
11631
+ InvalidModifierOnTypeParameterPositions: _(_ref82 => {
11632
+ var {
11633
+ modifier
11634
+ } = _ref82;
11635
+ return "'".concat(modifier, "' modifier can only appear on a type parameter of a class, interface or type alias.");
11636
+ }),
11637
+ InvalidModifiersOrder: _(_ref83 => {
11638
+ var {
11639
+ orderedModifiers
11640
+ } = _ref83;
11620
11641
  return "'".concat(orderedModifiers[0], "' modifier must precede '").concat(orderedModifiers[1], "' modifier.");
11621
11642
  }),
11622
11643
  InvalidTupleMemberLabel: _("Tuple members must be labeled with a simple identifier."),
@@ -11628,10 +11649,10 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11628
11649
  OverrideNotInSubClass: _("This member cannot have an 'override' modifier because its containing class does not extend another class."),
11629
11650
  PatternIsOptional: _("A binding pattern parameter cannot be optional in an implementation signature."),
11630
11651
  PrivateElementHasAbstract: _("Private elements cannot have the 'abstract' modifier."),
11631
- PrivateElementHasAccessibility: _(_ref82 => {
11652
+ PrivateElementHasAccessibility: _(_ref84 => {
11632
11653
  var {
11633
11654
  modifier
11634
- } = _ref82;
11655
+ } = _ref84;
11635
11656
  return "Private elements cannot have an accessibility modifier ('".concat(modifier, "').");
11636
11657
  }),
11637
11658
  ReadonlyForMethodSignature: _("'readonly' modifier can only appear on a property declaration or index signature."),
@@ -11640,10 +11661,10 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11640
11661
  SetAccesorCannotHaveOptionalParameter: _("A 'set' accessor cannot have an optional parameter."),
11641
11662
  SetAccesorCannotHaveRestParameter: _("A 'set' accessor cannot have rest parameter."),
11642
11663
  SetAccesorCannotHaveReturnType: _("A 'set' accessor cannot have a return type annotation."),
11643
- SingleTypeParameterWithoutTrailingComma: _(_ref83 => {
11664
+ SingleTypeParameterWithoutTrailingComma: _(_ref85 => {
11644
11665
  var {
11645
11666
  typeParameterName
11646
- } = _ref83;
11667
+ } = _ref85;
11647
11668
  return "Single type parameter ".concat(typeParameterName, " should have a trailing comma. Example usage: <").concat(typeParameterName, ",>.");
11648
11669
  }),
11649
11670
  StaticBlockCannotHaveModifier: _("Static class blocks cannot have any modifier."),
@@ -11657,10 +11678,10 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11657
11678
  UnexpectedTypeCastInParameter: _("Unexpected type cast in parameter position."),
11658
11679
  UnsupportedImportTypeArgument: _("Argument in a type import must be a string literal."),
11659
11680
  UnsupportedParameterPropertyKind: _("A parameter property may not be declared using a binding pattern."),
11660
- UnsupportedSignatureParameterKind: _(_ref84 => {
11681
+ UnsupportedSignatureParameterKind: _(_ref86 => {
11661
11682
  var {
11662
11683
  type
11663
- } = _ref84;
11684
+ } = _ref86;
11664
11685
  return "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ".concat(type, ".");
11665
11686
  })
11666
11687
  }));
@@ -11706,6 +11727,10 @@ function tsIsAccessModifier(modifier) {
11706
11727
  return modifier === "private" || modifier === "public" || modifier === "protected";
11707
11728
  }
11708
11729
 
11730
+ function tsIsVarianceAnnotations(modifier) {
11731
+ return modifier === "in" || modifier === "out";
11732
+ }
11733
+
11709
11734
  var typescript = superClass => class extends superClass {
11710
11735
  getScopeHandler() {
11711
11736
  return TypeScriptScopeHandler;
@@ -11725,7 +11750,7 @@ var typescript = superClass => class extends superClass {
11725
11750
  }
11726
11751
 
11727
11752
  tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
11728
- if (!tokenIsIdentifier(this.state.type)) {
11753
+ if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58) {
11729
11754
  return undefined;
11730
11755
  }
11731
11756
 
@@ -11744,13 +11769,14 @@ var typescript = superClass => class extends superClass {
11744
11769
  return undefined;
11745
11770
  }
11746
11771
 
11747
- tsParseModifiers(_ref85) {
11772
+ tsParseModifiers(_ref87) {
11748
11773
  var {
11749
11774
  modified,
11750
11775
  allowedModifiers,
11751
11776
  disallowedModifiers,
11752
- stopOnStartOfClassStaticBlock
11753
- } = _ref85;
11777
+ stopOnStartOfClassStaticBlock,
11778
+ errorTemplate = TSErrors.InvalidModifierOnTypeMember
11779
+ } = _ref87;
11754
11780
 
11755
11781
  var enforceOrder = (loc, modifier, before, after) => {
11756
11782
  if (modifier === before && modified[after]) {
@@ -11789,6 +11815,16 @@ var typescript = superClass => class extends superClass {
11789
11815
  enforceOrder(startLoc, modifier, modifier, "readonly");
11790
11816
  modified.accessibility = modifier;
11791
11817
  }
11818
+ } else if (tsIsVarianceAnnotations(modifier)) {
11819
+ if (modified[modifier]) {
11820
+ this.raise(TSErrors.DuplicateModifier, {
11821
+ at: startLoc,
11822
+ modifier
11823
+ });
11824
+ }
11825
+
11826
+ modified[modifier] = true;
11827
+ enforceOrder(startLoc, modifier, "in", "out");
11792
11828
  } else {
11793
11829
  if (Object.hasOwnProperty.call(modified, modifier)) {
11794
11830
  this.raise(TSErrors.DuplicateModifier, {
@@ -11808,7 +11844,7 @@ var typescript = superClass => class extends superClass {
11808
11844
  }
11809
11845
 
11810
11846
  if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
11811
- this.raise(TSErrors.InvalidModifierOnTypeMember, {
11847
+ this.raise(errorTemplate, {
11812
11848
  at: startLoc,
11813
11849
  modifier
11814
11850
  });
@@ -11985,24 +12021,48 @@ var typescript = superClass => class extends superClass {
11985
12021
  node.exprName = this.tsParseEntityName();
11986
12022
  }
11987
12023
 
12024
+ if (!this.hasPrecedingLineBreak() && this.match(47)) {
12025
+ node.typeParameters = this.tsParseTypeArguments();
12026
+ }
12027
+
11988
12028
  return this.finishNode(node, "TSTypeQuery");
11989
12029
  }
11990
12030
 
12031
+ tsParseInOutModifiers(node) {
12032
+ this.tsParseModifiers({
12033
+ modified: node,
12034
+ allowedModifiers: ["in", "out"],
12035
+ disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
12036
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameter
12037
+ });
12038
+ }
12039
+
12040
+ tsParseNoneModifiers(node) {
12041
+ this.tsParseModifiers({
12042
+ modified: node,
12043
+ allowedModifiers: [],
12044
+ disallowedModifiers: ["in", "out"],
12045
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
12046
+ });
12047
+ }
12048
+
11991
12049
  tsParseTypeParameter() {
12050
+ var parseModifiers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.tsParseNoneModifiers.bind(this);
11992
12051
  var node = this.startNode();
12052
+ parseModifiers(node);
11993
12053
  node.name = this.tsParseTypeParameterName();
11994
12054
  node.constraint = this.tsEatThenParseType(81);
11995
12055
  node.default = this.tsEatThenParseType(29);
11996
12056
  return this.finishNode(node, "TSTypeParameter");
11997
12057
  }
11998
12058
 
11999
- tsTryParseTypeParameters() {
12059
+ tsTryParseTypeParameters(parseModifiers) {
12000
12060
  if (this.match(47)) {
12001
- return this.tsParseTypeParameters();
12061
+ return this.tsParseTypeParameters(parseModifiers);
12002
12062
  }
12003
12063
  }
12004
12064
 
12005
- tsParseTypeParameters() {
12065
+ tsParseTypeParameters(parseModifiers) {
12006
12066
  var node = this.startNode();
12007
12067
 
12008
12068
  if (this.match(47) || this.match(138)) {
@@ -12014,7 +12074,7 @@ var typescript = superClass => class extends superClass {
12014
12074
  var refTrailingCommaPos = {
12015
12075
  value: -1
12016
12076
  };
12017
- node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
12077
+ node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
12018
12078
 
12019
12079
  if (node.params.length === 0) {
12020
12080
  this.raise(TSErrors.EmptyTypeParameters, {
@@ -12405,7 +12465,7 @@ var typescript = superClass => class extends superClass {
12405
12465
  this.next();
12406
12466
  }
12407
12467
 
12408
- this.tsFillSignature(19, node);
12468
+ this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
12409
12469
  return this.finishNode(node, type);
12410
12470
  }
12411
12471
 
@@ -12574,13 +12634,24 @@ var typescript = superClass => class extends superClass {
12574
12634
  this.expectContextual(112);
12575
12635
  var typeParameter = this.startNode();
12576
12636
  typeParameter.name = this.tsParseTypeParameterName();
12637
+ typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
12577
12638
  node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
12578
12639
  return this.finishNode(node, "TSInferType");
12579
12640
  }
12580
12641
 
12642
+ tsParseConstraintForInferType() {
12643
+ if (this.eat(81)) {
12644
+ var constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
12645
+
12646
+ if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
12647
+ return constraint;
12648
+ }
12649
+ }
12650
+ }
12651
+
12581
12652
  tsParseTypeOperatorOrHigher() {
12582
12653
  var isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
12583
- return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
12654
+ return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
12584
12655
  }
12585
12656
 
12586
12657
  tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
@@ -12782,17 +12853,17 @@ var typescript = superClass => class extends superClass {
12782
12853
  assert(this.state.inType);
12783
12854
  var type = this.tsParseNonConditionalType();
12784
12855
 
12785
- if (this.hasPrecedingLineBreak() || !this.eat(81)) {
12856
+ if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
12786
12857
  return type;
12787
12858
  }
12788
12859
 
12789
12860
  var node = this.startNodeAtNode(type);
12790
12861
  node.checkType = type;
12791
- node.extendsType = this.tsParseNonConditionalType();
12862
+ node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
12792
12863
  this.expect(17);
12793
- node.trueType = this.tsParseType();
12864
+ node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
12794
12865
  this.expect(14);
12795
- node.falseType = this.tsParseType();
12866
+ node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
12796
12867
  return this.finishNode(node, "TSConditionalType");
12797
12868
  }
12798
12869
 
@@ -12833,7 +12904,16 @@ var typescript = superClass => class extends superClass {
12833
12904
 
12834
12905
  tsParseHeritageClause(token) {
12835
12906
  var originalStartLoc = this.state.startLoc;
12836
- var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
12907
+ var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
12908
+ var node = this.startNode();
12909
+ node.expression = this.tsParseEntityName();
12910
+
12911
+ if (this.match(47)) {
12912
+ node.typeParameters = this.tsParseTypeArguments();
12913
+ }
12914
+
12915
+ return this.finishNode(node, "TSExpressionWithTypeArguments");
12916
+ });
12837
12917
 
12838
12918
  if (!delimitedList.length) {
12839
12919
  this.raise(TSErrors.EmptyHeritageClauseType, {
@@ -12845,17 +12925,6 @@ var typescript = superClass => class extends superClass {
12845
12925
  return delimitedList;
12846
12926
  }
12847
12927
 
12848
- tsParseExpressionWithTypeArguments() {
12849
- var node = this.startNode();
12850
- node.expression = this.tsParseEntityName();
12851
-
12852
- if (this.match(47)) {
12853
- node.typeParameters = this.tsParseTypeArguments();
12854
- }
12855
-
12856
- return this.finishNode(node, "TSExpressionWithTypeArguments");
12857
- }
12858
-
12859
12928
  tsParseInterfaceDeclaration(node) {
12860
12929
  var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12861
12930
  if (this.hasFollowingLineBreak()) return null;
@@ -12872,7 +12941,7 @@ var typescript = superClass => class extends superClass {
12872
12941
  });
12873
12942
  }
12874
12943
 
12875
- node.typeParameters = this.tsTryParseTypeParameters();
12944
+ node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
12876
12945
 
12877
12946
  if (this.eat(81)) {
12878
12947
  node.extends = this.tsParseHeritageClause("extends");
@@ -12888,7 +12957,7 @@ var typescript = superClass => class extends superClass {
12888
12957
  node.id = this.parseIdentifier();
12889
12958
  this.checkIdentifier(node.id, BIND_TS_TYPE);
12890
12959
  node.typeAnnotation = this.tsInType(() => {
12891
- node.typeParameters = this.tsTryParseTypeParameters();
12960
+ node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
12892
12961
  this.expect(29);
12893
12962
 
12894
12963
  if (this.isContextual(111) && this.lookahead().type !== 16) {
@@ -12926,6 +12995,28 @@ var typescript = superClass => class extends superClass {
12926
12995
  }
12927
12996
  }
12928
12997
 
12998
+ tsInDisallowConditionalTypesContext(cb) {
12999
+ var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
13000
+ this.state.inDisallowConditionalTypesContext = true;
13001
+
13002
+ try {
13003
+ return cb();
13004
+ } finally {
13005
+ this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
13006
+ }
13007
+ }
13008
+
13009
+ tsInAllowConditionalTypesContext(cb) {
13010
+ var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
13011
+ this.state.inDisallowConditionalTypesContext = false;
13012
+
13013
+ try {
13014
+ return cb();
13015
+ } finally {
13016
+ this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
13017
+ }
13018
+ }
13019
+
12929
13020
  tsEatThenParseType(token) {
12930
13021
  return !this.match(token) ? undefined : this.tsNextThenParseType();
12931
13022
  }
@@ -13445,35 +13536,44 @@ var typescript = superClass => class extends superClass {
13445
13536
  }
13446
13537
  }
13447
13538
 
13448
- var node = this.startNodeAt(startPos, startLoc);
13449
- node.callee = base;
13450
13539
  var typeArguments = this.tsParseTypeArgumentsInExpression();
13540
+ if (!typeArguments) throw this.unexpected();
13451
13541
 
13452
- if (typeArguments) {
13453
- if (isOptionalCall && !this.match(10)) {
13454
- missingParenErrorLoc = this.state.curPosition();
13455
- this.unexpected();
13456
- }
13542
+ if (isOptionalCall && !this.match(10)) {
13543
+ missingParenErrorLoc = this.state.curPosition();
13544
+ throw this.unexpected();
13545
+ }
13457
13546
 
13458
- if (!noCalls && this.eat(10)) {
13459
- node.arguments = this.parseCallExpressionArguments(11, false);
13460
- this.tsCheckForInvalidTypeCasts(node.arguments);
13461
- node.typeParameters = typeArguments;
13547
+ if (tokenIsTemplate(this.state.type)) {
13548
+ var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
13462
13549
 
13463
- if (state.optionalChainMember) {
13464
- node.optional = isOptionalCall;
13465
- }
13550
+ _result.typeParameters = typeArguments;
13551
+ return _result;
13552
+ }
13553
+
13554
+ if (!noCalls && this.eat(10)) {
13555
+ var _node9 = this.startNodeAt(startPos, startLoc);
13466
13556
 
13467
- return this.finishCallExpression(node, state.optionalChainMember);
13468
- } else if (tokenIsTemplate(this.state.type)) {
13469
- var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
13557
+ _node9.callee = base;
13558
+ _node9.arguments = this.parseCallExpressionArguments(11, false);
13559
+ this.tsCheckForInvalidTypeCasts(_node9.arguments);
13560
+ _node9.typeParameters = typeArguments;
13470
13561
 
13471
- _result.typeParameters = typeArguments;
13472
- return _result;
13562
+ if (state.optionalChainMember) {
13563
+ _node9.optional = isOptionalCall;
13473
13564
  }
13565
+
13566
+ return this.finishCallExpression(_node9, state.optionalChainMember);
13474
13567
  }
13475
13568
 
13476
- this.unexpected();
13569
+ if (tsTokenCanStartExpression(this.state.type) && this.state.type !== 10) {
13570
+ throw this.unexpected();
13571
+ }
13572
+
13573
+ var node = this.startNodeAt(startPos, startLoc);
13574
+ node.expression = base;
13575
+ node.typeParameters = typeArguments;
13576
+ return this.finishNode(node, "TSInstantiationExpression");
13477
13577
  });
13478
13578
 
13479
13579
  if (missingParenErrorLoc) {
@@ -13486,20 +13586,18 @@ var typescript = superClass => class extends superClass {
13486
13586
  return super.parseSubscript(base, startPos, startLoc, noCalls, state);
13487
13587
  }
13488
13588
 
13489
- parseNewArguments(node) {
13490
- if (this.match(47) || this.match(51)) {
13491
- var typeParameters = this.tsTryParseAndCatch(() => {
13492
- var args = this.tsParseTypeArgumentsInExpression();
13493
- if (!this.match(10)) this.unexpected();
13494
- return args;
13495
- });
13589
+ parseNewCallee(node) {
13590
+ var _callee$extra;
13496
13591
 
13497
- if (typeParameters) {
13498
- node.typeParameters = typeParameters;
13499
- }
13500
- }
13592
+ super.parseNewCallee(node);
13593
+ var {
13594
+ callee
13595
+ } = node;
13501
13596
 
13502
- super.parseNewArguments(node);
13597
+ if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
13598
+ node.typeParameters = callee.typeParameters;
13599
+ node.callee = callee.expression;
13600
+ }
13503
13601
  }
13504
13602
 
13505
13603
  parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
@@ -13687,7 +13785,9 @@ var typescript = superClass => class extends superClass {
13687
13785
  this.tsParseModifiers({
13688
13786
  modified: member,
13689
13787
  allowedModifiers: modifiers,
13690
- stopOnStartOfClassStaticBlock: true
13788
+ disallowedModifiers: ["in", "out"],
13789
+ stopOnStartOfClassStaticBlock: true,
13790
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
13691
13791
  });
13692
13792
 
13693
13793
  var callParseClassMemberWithIsStatic = () => {
@@ -13866,7 +13966,7 @@ var typescript = superClass => class extends superClass {
13866
13966
  }
13867
13967
 
13868
13968
  super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS);
13869
- var typeParameters = this.tsTryParseTypeParameters();
13969
+ var typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
13870
13970
  if (typeParameters) node.typeParameters = typeParameters;
13871
13971
  }
13872
13972
 
@@ -13972,8 +14072,8 @@ var typescript = superClass => class extends superClass {
13972
14072
  var typeParameters = this.tsTryParseTypeParameters();
13973
14073
  if (typeParameters) prop.typeParameters = typeParameters;
13974
14074
 
13975
- for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
13976
- args[_key5 - 1] = arguments[_key5];
14075
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
14076
+ args[_key4 - 1] = arguments[_key4];
13977
14077
  }
13978
14078
 
13979
14079
  super.parseObjPropValue(prop, ...args);
@@ -14009,8 +14109,8 @@ var typescript = superClass => class extends superClass {
14009
14109
  }
14010
14110
 
14011
14111
  parseMaybeAssign() {
14012
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
14013
- args[_key6] = arguments[_key6];
14112
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
14113
+ args[_key5] = arguments[_key5];
14014
14114
  }
14015
14115
 
14016
14116
  var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2, _jsx4, _typeCast3;
@@ -14037,10 +14137,10 @@ var typescript = superClass => class extends superClass {
14037
14137
  return super.parseMaybeAssign(...args);
14038
14138
  }
14039
14139
 
14140
+ if (!state || state === this.state) state = this.state.clone();
14040
14141
  var typeParameters;
14041
- state = state || this.state.clone();
14042
14142
  var arrow = this.tryParse(abort => {
14043
- var _expr$extra, _typeParameters, _expr$typeParameters$;
14143
+ var _expr$extra, _typeParameters;
14044
14144
 
14045
14145
  typeParameters = this.tsParseTypeParameters();
14046
14146
  var expr = super.parseMaybeAssign(...args);
@@ -14054,12 +14154,6 @@ var typescript = superClass => class extends superClass {
14054
14154
  }
14055
14155
 
14056
14156
  expr.typeParameters = typeParameters;
14057
-
14058
- if (this.hasPlugin("jsx") && expr.typeParameters.params.length === 1 && !((_expr$typeParameters$ = expr.typeParameters.extra) != null && _expr$typeParameters$.trailingComma)) {
14059
- var parameter = expr.typeParameters.params[0];
14060
- if (!parameter.constraint) ;
14061
- }
14062
-
14063
14157
  return expr;
14064
14158
  }, state);
14065
14159
 
@@ -14166,23 +14260,33 @@ var typescript = superClass => class extends superClass {
14166
14260
  var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
14167
14261
 
14168
14262
  switch (node.type) {
14169
- case "TSTypeCastExpression":
14170
- return super.toAssignable(this.typeCastToParameter(node), isLHS);
14171
-
14172
- case "TSParameterProperty":
14173
- return super.toAssignable(node, isLHS);
14174
-
14175
14263
  case "ParenthesizedExpression":
14176
- return this.toAssignableParenthesizedExpression(node, isLHS);
14264
+ this.toAssignableParenthesizedExpression(node, isLHS);
14265
+ break;
14177
14266
 
14178
14267
  case "TSAsExpression":
14179
14268
  case "TSNonNullExpression":
14180
14269
  case "TSTypeAssertion":
14181
- node.expression = this.toAssignable(node.expression, isLHS);
14182
- return node;
14270
+ if (isLHS) {
14271
+ this.expressionScope.recordArrowParemeterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
14272
+ at: node
14273
+ });
14274
+ } else {
14275
+ this.raise(TSErrors.UnexpectedTypeCastInParameter, {
14276
+ at: node
14277
+ });
14278
+ }
14279
+
14280
+ this.toAssignable(node.expression, isLHS);
14281
+ break;
14282
+
14283
+ case "AssignmentExpression":
14284
+ if (!isLHS && node.left.type === "TSTypeCastExpression") {
14285
+ node.left = this.typeCastToParameter(node.left);
14286
+ }
14183
14287
 
14184
14288
  default:
14185
- return super.toAssignable(node, isLHS);
14289
+ super.toAssignable(node, isLHS);
14186
14290
  }
14187
14291
  }
14188
14292
 
@@ -14192,22 +14296,35 @@ var typescript = superClass => class extends superClass {
14192
14296
  case "TSNonNullExpression":
14193
14297
  case "TSTypeAssertion":
14194
14298
  case "ParenthesizedExpression":
14195
- node.expression = this.toAssignable(node.expression, isLHS);
14196
- return node;
14299
+ this.toAssignable(node.expression, isLHS);
14300
+ break;
14301
+
14302
+ default:
14303
+ super.toAssignable(node, isLHS);
14304
+ }
14305
+ }
14306
+
14307
+ checkToRestConversion(node, allowPattern) {
14308
+ switch (node.type) {
14309
+ case "TSAsExpression":
14310
+ case "TSTypeAssertion":
14311
+ case "TSNonNullExpression":
14312
+ this.checkToRestConversion(node.expression, false);
14313
+ break;
14197
14314
 
14198
14315
  default:
14199
- return super.toAssignable(node, isLHS);
14316
+ super.checkToRestConversion(node, allowPattern);
14200
14317
  }
14201
14318
  }
14202
14319
 
14203
- isValidLVal(type, isParenthesized, binding) {
14320
+ isValidLVal(type, isUnparenthesizedInAssign, binding) {
14204
14321
  return getOwn$1({
14205
14322
  TSTypeCastExpression: true,
14206
14323
  TSParameterProperty: "parameter",
14207
14324
  TSNonNullExpression: "expression",
14208
- TSAsExpression: (binding !== BIND_NONE || isParenthesized) && ["expression", true],
14209
- TSTypeAssertion: (binding !== BIND_NONE || isParenthesized) && ["expression", true]
14210
- }, type) || super.isValidLVal(type, isParenthesized, binding);
14325
+ TSAsExpression: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true],
14326
+ TSTypeAssertion: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true]
14327
+ }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
14211
14328
  }
14212
14329
 
14213
14330
  parseBindingAtom() {
@@ -14310,28 +14427,13 @@ var typescript = superClass => class extends superClass {
14310
14427
  toAssignableList(exprList) {
14311
14428
  for (var i = 0; i < exprList.length; i++) {
14312
14429
  var expr = exprList[i];
14313
- if (!expr) continue;
14314
14430
 
14315
- switch (expr.type) {
14316
- case "TSTypeCastExpression":
14317
- exprList[i] = this.typeCastToParameter(expr);
14318
- break;
14319
-
14320
- case "TSAsExpression":
14321
- case "TSTypeAssertion":
14322
- if (!this.state.maybeInArrowParameters) {
14323
- exprList[i] = this.typeCastToParameter(expr);
14324
- } else {
14325
- this.raise(TSErrors.UnexpectedTypeCastInParameter, {
14326
- at: expr
14327
- });
14328
- }
14329
-
14330
- break;
14431
+ if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
14432
+ exprList[i] = this.typeCastToParameter(expr);
14331
14433
  }
14332
14434
  }
14333
14435
 
14334
- return super.toAssignableList(...arguments);
14436
+ super.toAssignableList(...arguments);
14335
14437
  }
14336
14438
 
14337
14439
  typeCastToParameter(node) {
@@ -14401,8 +14503,8 @@ var typescript = superClass => class extends superClass {
14401
14503
  this.state.inAbstractClass = !!node.abstract;
14402
14504
 
14403
14505
  try {
14404
- for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
14405
- args[_key7 - 1] = arguments[_key7];
14506
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
14507
+ args[_key6 - 1] = arguments[_key6];
14406
14508
  }
14407
14509
 
14408
14510
  return super.parseClass(node, ...args);
@@ -14526,7 +14628,16 @@ var typescript = superClass => class extends superClass {
14526
14628
  }
14527
14629
  } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14528
14630
  hasTypeSpecifier = true;
14529
- leftOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
14631
+
14632
+ if (isImport) {
14633
+ leftOfAs = this.parseIdentifier(true);
14634
+
14635
+ if (!this.isContextual(93)) {
14636
+ this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
14637
+ }
14638
+ } else {
14639
+ leftOfAs = this.parseModuleExportName();
14640
+ }
14530
14641
  }
14531
14642
 
14532
14643
  if (hasTypeSpecifier && isInTypeOnlyImportExport) {
@@ -14625,8 +14736,8 @@ var placeholders = superClass => class extends superClass {
14625
14736
  }
14626
14737
 
14627
14738
  isValidLVal(type) {
14628
- for (var _len8 = arguments.length, rest = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
14629
- rest[_key8 - 1] = arguments[_key8];
14739
+ for (var _len7 = arguments.length, rest = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
14740
+ rest[_key7 - 1] = arguments[_key7];
14630
14741
  }
14631
14742
 
14632
14743
  return type === "Placeholder" || super.isValidLVal(type, ...rest);
@@ -14635,10 +14746,9 @@ var placeholders = superClass => class extends superClass {
14635
14746
  toAssignable(node) {
14636
14747
  if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
14637
14748
  node.expectedNode = "Pattern";
14638
- return node;
14749
+ } else {
14750
+ super.toAssignable(...arguments);
14639
14751
  }
14640
-
14641
- return super.toAssignable(...arguments);
14642
14752
  }
14643
14753
 
14644
14754
  isLet(context) {
@@ -14950,9 +15060,9 @@ function validatePlugins(plugins) {
14950
15060
  throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
14951
15061
  }
14952
15062
 
14953
- var moduleAttributesVerionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
15063
+ var moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
14954
15064
 
14955
- if (moduleAttributesVerionPluginOption !== "may-2020") {
15065
+ if (moduleAttributesVersionPluginOption !== "may-2020") {
14956
15066
  throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
14957
15067
  }
14958
15068
  }
@@ -15026,7 +15136,7 @@ class LValParser extends NodeUtils {
15026
15136
 
15027
15137
  if (isLHS) {
15028
15138
  if (parenthesized.type === "Identifier") {
15029
- this.expressionScope.recordParenthesizedIdentifierError({
15139
+ this.expressionScope.recordArrowParemeterBindingError(Errors.InvalidParenthesizedAssignment, {
15030
15140
  at: node
15031
15141
  });
15032
15142
  } else if (parenthesized.type !== "MemberExpression") {
@@ -15085,11 +15195,7 @@ class LValParser extends NodeUtils {
15085
15195
 
15086
15196
  case "SpreadElement":
15087
15197
  {
15088
- this.checkToRestConversion(node);
15089
- node.type = "RestElement";
15090
- var arg = node.argument;
15091
- this.toAssignable(arg, isLHS);
15092
- break;
15198
+ throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
15093
15199
  }
15094
15200
 
15095
15201
  case "ArrayExpression":
@@ -15113,8 +15219,6 @@ class LValParser extends NodeUtils {
15113
15219
  this.toAssignable(parenthesized, isLHS);
15114
15220
  break;
15115
15221
  }
15116
-
15117
- return node;
15118
15222
  }
15119
15223
 
15120
15224
  toAssignableObjectExpressionProp(prop, isLast, isLHS) {
@@ -15122,58 +15226,50 @@ class LValParser extends NodeUtils {
15122
15226
  this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, {
15123
15227
  at: prop.key
15124
15228
  });
15125
- } else if (prop.type === "SpreadElement" && !isLast) {
15126
- this.raise(Errors.RestTrailingComma, {
15127
- at: prop
15128
- });
15229
+ } else if (prop.type === "SpreadElement") {
15230
+ prop.type = "RestElement";
15231
+ var arg = prop.argument;
15232
+ this.checkToRestConversion(arg, false);
15233
+ this.toAssignable(arg, isLHS);
15234
+
15235
+ if (!isLast) {
15236
+ this.raise(Errors.RestTrailingComma, {
15237
+ at: prop
15238
+ });
15239
+ }
15129
15240
  } else {
15130
15241
  this.toAssignable(prop, isLHS);
15131
15242
  }
15132
15243
  }
15133
15244
 
15134
15245
  toAssignableList(exprList, trailingCommaLoc, isLHS) {
15135
- var end = exprList.length;
15136
-
15137
- if (end) {
15138
- var last = exprList[end - 1];
15139
-
15140
- if ((last == null ? void 0 : last.type) === "RestElement") {
15141
- --end;
15142
- } else if ((last == null ? void 0 : last.type) === "SpreadElement") {
15143
- last.type = "RestElement";
15144
- var arg = last.argument;
15145
- this.toAssignable(arg, isLHS);
15146
- arg = unwrapParenthesizedExpression(arg);
15147
-
15148
- if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
15149
- this.unexpected(arg.start);
15150
- }
15246
+ var end = exprList.length - 1;
15151
15247
 
15152
- if (trailingCommaLoc) {
15153
- this.raise(Errors.RestTrailingComma, {
15154
- at: trailingCommaLoc
15155
- });
15156
- }
15157
-
15158
- --end;
15159
- }
15160
- }
15161
-
15162
- for (var i = 0; i < end; i++) {
15248
+ for (var i = 0; i <= end; i++) {
15163
15249
  var elt = exprList[i];
15250
+ if (!elt) continue;
15164
15251
 
15165
- if (elt) {
15252
+ if (elt.type === "SpreadElement") {
15253
+ elt.type = "RestElement";
15254
+ var arg = elt.argument;
15255
+ this.checkToRestConversion(arg, true);
15256
+ this.toAssignable(arg, isLHS);
15257
+ } else {
15166
15258
  this.toAssignable(elt, isLHS);
15259
+ }
15167
15260
 
15168
- if (elt.type === "RestElement") {
15261
+ if (elt.type === "RestElement") {
15262
+ if (i < end) {
15169
15263
  this.raise(Errors.RestTrailingComma, {
15170
15264
  at: elt
15171
15265
  });
15266
+ } else if (trailingCommaLoc) {
15267
+ this.raise(Errors.RestTrailingComma, {
15268
+ at: trailingCommaLoc
15269
+ });
15172
15270
  }
15173
15271
  }
15174
15272
  }
15175
-
15176
- return exprList;
15177
15273
  }
15178
15274
 
15179
15275
  isAssignable(node, isBinding) {
@@ -15363,7 +15459,7 @@ class LValParser extends NodeUtils {
15363
15459
  return this.finishNode(node, "AssignmentPattern");
15364
15460
  }
15365
15461
 
15366
- isValidLVal(type, isParenthesized, binding) {
15462
+ isValidLVal(type, isUnparenthesizedInAssign, binding) {
15367
15463
  return getOwn({
15368
15464
  AssignmentPattern: "left",
15369
15465
  RestElement: "argument",
@@ -15374,7 +15470,7 @@ class LValParser extends NodeUtils {
15374
15470
  }, type);
15375
15471
  }
15376
15472
 
15377
- checkLVal(expression, _ref86) {
15473
+ checkLVal(expression, _ref88) {
15378
15474
  var {
15379
15475
  in: ancestor,
15380
15476
  binding = BIND_NONE,
@@ -15382,7 +15478,7 @@ class LValParser extends NodeUtils {
15382
15478
  strictModeChanged = false,
15383
15479
  allowingSloppyLetBinding = !(binding & BIND_SCOPE_LEXICAL),
15384
15480
  hasParenthesizedAncestor = false
15385
- } = _ref86;
15481
+ } = _ref88;
15386
15482
 
15387
15483
  var _expression$extra;
15388
15484
 
@@ -15418,7 +15514,7 @@ class LValParser extends NodeUtils {
15418
15514
  return;
15419
15515
  }
15420
15516
 
15421
- var validity = this.isValidLVal(expression.type, hasParenthesizedAncestor || ((_expression$extra = expression.extra) == null ? void 0 : _expression$extra.parenthesized), binding);
15517
+ var validity = this.isValidLVal(expression.type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
15422
15518
  if (validity === true) return;
15423
15519
 
15424
15520
  if (validity === false) {
@@ -15485,11 +15581,24 @@ class LValParser extends NodeUtils {
15485
15581
  this.scope.declareName(identifier.name, binding, identifier.loc.start);
15486
15582
  }
15487
15583
 
15488
- checkToRestConversion(node) {
15489
- if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
15490
- this.raise(Errors.InvalidRestAssignmentPattern, {
15491
- at: node.argument
15492
- });
15584
+ checkToRestConversion(node, allowPattern) {
15585
+ switch (node.type) {
15586
+ case "ParenthesizedExpression":
15587
+ this.checkToRestConversion(node.expression, allowPattern);
15588
+ break;
15589
+
15590
+ case "Identifier":
15591
+ case "MemberExpression":
15592
+ break;
15593
+
15594
+ case "ArrayExpression":
15595
+ case "ObjectExpression":
15596
+ if (allowPattern) break;
15597
+
15598
+ default:
15599
+ this.raise(Errors.InvalidRestAssignmentPattern, {
15600
+ at: node
15601
+ });
15493
15602
  }
15494
15603
  }
15495
15604
 
@@ -15650,7 +15759,8 @@ class ExpressionParser extends LValParser {
15650
15759
  node.operator = operator;
15651
15760
 
15652
15761
  if (this.match(29)) {
15653
- node.left = this.toAssignable(left, true);
15762
+ this.toAssignable(left, true);
15763
+ node.left = left;
15654
15764
 
15655
15765
  if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startPos) {
15656
15766
  refExpressionErrors.doubleProtoLoc = null;
@@ -15950,14 +16060,14 @@ class ExpressionParser extends LValParser {
15950
16060
  if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
15951
16061
 
15952
16062
  while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
15953
- var _node9 = this.startNodeAt(startPos, startLoc);
16063
+ var _node10 = this.startNodeAt(startPos, startLoc);
15954
16064
 
15955
- _node9.operator = this.state.value;
15956
- _node9.prefix = false;
15957
- _node9.argument = expr;
16065
+ _node10.operator = this.state.value;
16066
+ _node10.prefix = false;
16067
+ _node10.argument = expr;
15958
16068
  this.next();
15959
16069
  this.checkLVal(expr, {
15960
- in: expr = this.finishNode(_node9, "UpdateExpression")
16070
+ in: expr = this.finishNode(_node10, "UpdateExpression")
15961
16071
  });
15962
16072
  }
15963
16073
 
@@ -16817,6 +16927,20 @@ class ExpressionParser extends LValParser {
16817
16927
  }
16818
16928
 
16819
16929
  parseNew(node) {
16930
+ this.parseNewCallee(node);
16931
+
16932
+ if (this.eat(10)) {
16933
+ var args = this.parseExprList(11);
16934
+ this.toReferencedList(args);
16935
+ node.arguments = args;
16936
+ } else {
16937
+ node.arguments = [];
16938
+ }
16939
+
16940
+ return this.finishNode(node, "NewExpression");
16941
+ }
16942
+
16943
+ parseNewCallee(node) {
16820
16944
  node.callee = this.parseNoCallExpr();
16821
16945
 
16822
16946
  if (node.callee.type === "Import") {
@@ -16832,19 +16956,6 @@ class ExpressionParser extends LValParser {
16832
16956
  at: this.state.startLoc
16833
16957
  });
16834
16958
  }
16835
-
16836
- this.parseNewArguments(node);
16837
- return this.finishNode(node, "NewExpression");
16838
- }
16839
-
16840
- parseNewArguments(node) {
16841
- if (this.eat(10)) {
16842
- var args = this.parseExprList(11);
16843
- this.toReferencedList(args);
16844
- node.arguments = args;
16845
- } else {
16846
- node.arguments = [];
16847
- }
16848
16959
  }
16849
16960
 
16850
16961
  parseTemplateElement(isTagged) {
@@ -17251,7 +17362,8 @@ class ExpressionParser extends LValParser {
17251
17362
  }
17252
17363
 
17253
17364
  setArrowFunctionParameters(node, params, trailingCommaLoc) {
17254
- node.params = this.toAssignableList(params, trailingCommaLoc, false);
17365
+ this.toAssignableList(params, trailingCommaLoc, false);
17366
+ node.params = params;
17255
17367
  }
17256
17368
 
17257
17369
  parseFunctionBodyAndFinish(node, type) {
@@ -18192,12 +18304,12 @@ class StatementParser extends ExpressionParser {
18192
18304
  expr = this.parseIdentifier(false);
18193
18305
 
18194
18306
  while (this.eat(16)) {
18195
- var _node10 = this.startNodeAt(startPos, startLoc);
18307
+ var _node11 = this.startNodeAt(startPos, startLoc);
18196
18308
 
18197
- _node10.object = expr;
18198
- _node10.property = this.parseIdentifier(true);
18199
- _node10.computed = false;
18200
- expr = this.finishNode(_node10, "MemberExpression");
18309
+ _node11.object = expr;
18310
+ _node11.property = this.parseIdentifier(true);
18311
+ _node11.computed = false;
18312
+ expr = this.finishNode(_node11, "MemberExpression");
18201
18313
  }
18202
18314
  }
18203
18315