@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.
@@ -836,6 +836,7 @@
836
836
  customTemplates.forEach(tpl => {
837
837
  selfDefined.add(tpl.name);
838
838
  collectBricksInBrickConfs(tpl.bricks, collection);
839
+ collectBricksInContext(tpl.state, collection);
839
840
  });
840
841
  }
841
842
  }
@@ -3612,8 +3613,8 @@
3612
3613
  });
3613
3614
 
3614
3615
  function toESTreeLocation(node) {
3615
- toUnenumerable(node.loc.start, "index");
3616
- toUnenumerable(node.loc.end, "index");
3616
+ node.loc.start && toUnenumerable(node.loc.start, "index");
3617
+ node.loc.end && toUnenumerable(node.loc.end, "index");
3617
3618
  return node;
3618
3619
  }
3619
3620
 
@@ -3887,10 +3888,9 @@
3887
3888
  }
3888
3889
 
3889
3890
  this.toAssignable(value, isLHS);
3890
- return node;
3891
+ } else {
3892
+ super.toAssignable(node, isLHS);
3891
3893
  }
3892
-
3893
- return super.toAssignable(node, isLHS);
3894
3894
  }
3895
3895
 
3896
3896
  toAssignableObjectExpressionProp(prop) {
@@ -3903,11 +3903,7 @@
3903
3903
  at: prop.key
3904
3904
  });
3905
3905
  } else {
3906
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
3907
- args[_key3 - 1] = arguments[_key3];
3908
- }
3909
-
3910
- super.toAssignableObjectExpressionProp(prop, ...args);
3906
+ super.toAssignableObjectExpressionProp(...arguments);
3911
3907
  }
3912
3908
  }
3913
3909
 
@@ -4004,6 +4000,11 @@
4004
4000
  return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
4005
4001
  }
4006
4002
 
4003
+ resetStartLocation(node, start, startLoc) {
4004
+ super.resetStartLocation(node, start, startLoc);
4005
+ toESTreeLocation(node);
4006
+ }
4007
+
4007
4008
  resetEndLocation(node) {
4008
4009
  var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
4009
4010
  super.resetEndLocation(node, endLoc);
@@ -4151,9 +4152,7 @@
4151
4152
  beforeExpr,
4152
4153
  startsExpr
4153
4154
  }),
4154
- braceR: createToken("}", {
4155
- beforeExpr
4156
- }),
4155
+ braceR: createToken("}"),
4157
4156
  braceBarR: createToken("|}"),
4158
4157
  parenL: createToken("(", {
4159
4158
  beforeExpr,
@@ -4578,6 +4577,10 @@
4578
4577
  return tokenBinops[token];
4579
4578
  }
4580
4579
 
4580
+ function tokenIsBinaryOperator(token) {
4581
+ return tokenBinops[token] !== -1;
4582
+ }
4583
+
4581
4584
  function tokenIsRightAssociative(token) {
4582
4585
  return token === 57;
4583
4586
  }
@@ -5043,6 +5046,7 @@
5043
5046
  this.hasFlowComment = false;
5044
5047
  this.isAmbientContext = false;
5045
5048
  this.inAbstractClass = false;
5049
+ this.inDisallowConditionalTypesContext = false;
5046
5050
  this.topicContext = {
5047
5051
  maxNumOfResolvableTopics: 0,
5048
5052
  maxTopicIndex: null
@@ -7055,7 +7059,7 @@
7055
7059
  this.parser.raise(toParseError, origin);
7056
7060
  }
7057
7061
 
7058
- recordParenthesizedIdentifierError(_ref45) {
7062
+ recordArrowParemeterBindingError(error, _ref45) {
7059
7063
  var {
7060
7064
  at: node
7061
7065
  } = _ref45;
@@ -7068,9 +7072,9 @@
7068
7072
  };
7069
7073
 
7070
7074
  if (scope.isCertainlyParameterDeclaration()) {
7071
- this.parser.raise(Errors.InvalidParenthesizedAssignment, origin);
7075
+ this.parser.raise(error, origin);
7072
7076
  } else if (scope.canBeArrowParameterDeclaration()) {
7073
- scope.recordDeclarationError(Errors.InvalidParenthesizedAssignment, origin);
7077
+ scope.recordDeclarationError(error, origin);
7074
7078
  } else {
7075
7079
  return;
7076
7080
  }
@@ -9521,11 +9525,11 @@
9521
9525
  toAssignable(node) {
9522
9526
  var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9523
9527
 
9524
- if (node.type === "TypeCastExpression") {
9525
- return super.toAssignable(this.typeCastToParameter(node), isLHS);
9526
- } else {
9527
- return super.toAssignable(node, isLHS);
9528
+ if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
9529
+ node.left = this.typeCastToParameter(node.left);
9528
9530
  }
9531
+
9532
+ super.toAssignable(...arguments);
9529
9533
  }
9530
9534
 
9531
9535
  toAssignableList(exprList, trailingCommaLoc, isLHS) {
@@ -9537,7 +9541,7 @@
9537
9541
  }
9538
9542
  }
9539
9543
 
9540
- return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
9544
+ super.toAssignableList(exprList, trailingCommaLoc, isLHS);
9541
9545
  }
9542
9546
 
9543
9547
  toReferencedList(exprList, isParenthesizedExpr) {
@@ -9567,8 +9571,8 @@
9567
9571
  }
9568
9572
 
9569
9573
  isValidLVal(type) {
9570
- for (var _len4 = arguments.length, rest = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
9571
- rest[_key4 - 1] = arguments[_key4];
9574
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
9575
+ rest[_key3 - 1] = arguments[_key3];
9572
9576
  }
9573
9577
 
9574
9578
  return type === "TypeCastExpression" || super.isValidLVal(type, ...rest);
@@ -10117,7 +10121,8 @@
10117
10121
  return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState);
10118
10122
  }
10119
10123
 
10120
- parseNewArguments(node) {
10124
+ parseNewCallee(node) {
10125
+ super.parseNewCallee(node);
10121
10126
  var targs = null;
10122
10127
 
10123
10128
  if (this.shouldParseTypes() && this.match(47)) {
@@ -10125,7 +10130,6 @@
10125
10130
  }
10126
10131
 
10127
10132
  node.typeArguments = targs;
10128
- super.parseNewArguments(node);
10129
10133
  }
10130
10134
 
10131
10135
  parseAsyncArrowWithTypeParameters(startPos, startLoc) {
@@ -11198,6 +11202,7 @@
11198
11202
  this.next();
11199
11203
  node.expression = this.parseExpression();
11200
11204
  this.setContext(types.j_oTag);
11205
+ this.state.canStartJSXElement = true;
11201
11206
  this.expect(8);
11202
11207
  return this.finishNode(node, "JSXSpreadChild");
11203
11208
  }
@@ -11211,6 +11216,7 @@
11211
11216
  }
11212
11217
 
11213
11218
  this.setContext(previousContext);
11219
+ this.state.canStartJSXElement = true;
11214
11220
  this.expect(8);
11215
11221
  return this.finishNode(node, "JSXExpressionContainer");
11216
11222
  }
@@ -11224,6 +11230,7 @@
11224
11230
  this.expect(21);
11225
11231
  node.argument = this.parseMaybeAssignAllowIn();
11226
11232
  this.setContext(types.j_oTag);
11233
+ this.state.canStartJSXElement = true;
11227
11234
  this.expect(8);
11228
11235
  return this.finishNode(node, "JSXSpreadAttribute");
11229
11236
  }
@@ -11236,8 +11243,7 @@
11236
11243
  jsxParseOpeningElementAt(startPos, startLoc) {
11237
11244
  var node = this.startNodeAt(startPos, startLoc);
11238
11245
 
11239
- if (this.match(139)) {
11240
- this.expect(139);
11246
+ if (this.eat(139)) {
11241
11247
  return this.finishNode(node, "JSXOpeningFragment");
11242
11248
  }
11243
11249
 
@@ -11261,8 +11267,7 @@
11261
11267
  jsxParseClosingElementAt(startPos, startLoc) {
11262
11268
  var node = this.startNodeAt(startPos, startLoc);
11263
11269
 
11264
- if (this.match(139)) {
11265
- this.expect(139);
11270
+ if (this.eat(139)) {
11266
11271
  return this.finishNode(node, "JSXClosingFragment");
11267
11272
  }
11268
11273
 
@@ -11543,6 +11548,10 @@
11543
11548
  }
11544
11549
  }
11545
11550
 
11551
+ function tsTokenCanStartExpression(token) {
11552
+ return tokenCanStartExpression(token) || tokenIsBinaryOperator(token);
11553
+ }
11554
+
11546
11555
  var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["typescript"])))(_ => ({
11547
11556
  AbstractMethodHasImplementation: _(_ref71 => {
11548
11557
  var {
@@ -11618,10 +11627,22 @@
11618
11627
  } = _ref80;
11619
11628
  return "'".concat(modifier, "' modifier cannot appear on a type member.");
11620
11629
  }),
11621
- InvalidModifiersOrder: _(_ref81 => {
11630
+ InvalidModifierOnTypeParameter: _(_ref81 => {
11622
11631
  var {
11623
- orderedModifiers
11632
+ modifier
11624
11633
  } = _ref81;
11634
+ return "'".concat(modifier, "' modifier cannot appear on a type parameter.");
11635
+ }),
11636
+ InvalidModifierOnTypeParameterPositions: _(_ref82 => {
11637
+ var {
11638
+ modifier
11639
+ } = _ref82;
11640
+ return "'".concat(modifier, "' modifier can only appear on a type parameter of a class, interface or type alias.");
11641
+ }),
11642
+ InvalidModifiersOrder: _(_ref83 => {
11643
+ var {
11644
+ orderedModifiers
11645
+ } = _ref83;
11625
11646
  return "'".concat(orderedModifiers[0], "' modifier must precede '").concat(orderedModifiers[1], "' modifier.");
11626
11647
  }),
11627
11648
  InvalidTupleMemberLabel: _("Tuple members must be labeled with a simple identifier."),
@@ -11633,10 +11654,10 @@
11633
11654
  OverrideNotInSubClass: _("This member cannot have an 'override' modifier because its containing class does not extend another class."),
11634
11655
  PatternIsOptional: _("A binding pattern parameter cannot be optional in an implementation signature."),
11635
11656
  PrivateElementHasAbstract: _("Private elements cannot have the 'abstract' modifier."),
11636
- PrivateElementHasAccessibility: _(_ref82 => {
11657
+ PrivateElementHasAccessibility: _(_ref84 => {
11637
11658
  var {
11638
11659
  modifier
11639
- } = _ref82;
11660
+ } = _ref84;
11640
11661
  return "Private elements cannot have an accessibility modifier ('".concat(modifier, "').");
11641
11662
  }),
11642
11663
  ReadonlyForMethodSignature: _("'readonly' modifier can only appear on a property declaration or index signature."),
@@ -11645,10 +11666,10 @@
11645
11666
  SetAccesorCannotHaveOptionalParameter: _("A 'set' accessor cannot have an optional parameter."),
11646
11667
  SetAccesorCannotHaveRestParameter: _("A 'set' accessor cannot have rest parameter."),
11647
11668
  SetAccesorCannotHaveReturnType: _("A 'set' accessor cannot have a return type annotation."),
11648
- SingleTypeParameterWithoutTrailingComma: _(_ref83 => {
11669
+ SingleTypeParameterWithoutTrailingComma: _(_ref85 => {
11649
11670
  var {
11650
11671
  typeParameterName
11651
- } = _ref83;
11672
+ } = _ref85;
11652
11673
  return "Single type parameter ".concat(typeParameterName, " should have a trailing comma. Example usage: <").concat(typeParameterName, ",>.");
11653
11674
  }),
11654
11675
  StaticBlockCannotHaveModifier: _("Static class blocks cannot have any modifier."),
@@ -11662,10 +11683,10 @@
11662
11683
  UnexpectedTypeCastInParameter: _("Unexpected type cast in parameter position."),
11663
11684
  UnsupportedImportTypeArgument: _("Argument in a type import must be a string literal."),
11664
11685
  UnsupportedParameterPropertyKind: _("A parameter property may not be declared using a binding pattern."),
11665
- UnsupportedSignatureParameterKind: _(_ref84 => {
11686
+ UnsupportedSignatureParameterKind: _(_ref86 => {
11666
11687
  var {
11667
11688
  type
11668
- } = _ref84;
11689
+ } = _ref86;
11669
11690
  return "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ".concat(type, ".");
11670
11691
  })
11671
11692
  }));
@@ -11711,6 +11732,10 @@
11711
11732
  return modifier === "private" || modifier === "public" || modifier === "protected";
11712
11733
  }
11713
11734
 
11735
+ function tsIsVarianceAnnotations(modifier) {
11736
+ return modifier === "in" || modifier === "out";
11737
+ }
11738
+
11714
11739
  var typescript = superClass => class extends superClass {
11715
11740
  getScopeHandler() {
11716
11741
  return TypeScriptScopeHandler;
@@ -11730,7 +11755,7 @@
11730
11755
  }
11731
11756
 
11732
11757
  tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
11733
- if (!tokenIsIdentifier(this.state.type)) {
11758
+ if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58) {
11734
11759
  return undefined;
11735
11760
  }
11736
11761
 
@@ -11749,13 +11774,14 @@
11749
11774
  return undefined;
11750
11775
  }
11751
11776
 
11752
- tsParseModifiers(_ref85) {
11777
+ tsParseModifiers(_ref87) {
11753
11778
  var {
11754
11779
  modified,
11755
11780
  allowedModifiers,
11756
11781
  disallowedModifiers,
11757
- stopOnStartOfClassStaticBlock
11758
- } = _ref85;
11782
+ stopOnStartOfClassStaticBlock,
11783
+ errorTemplate = TSErrors.InvalidModifierOnTypeMember
11784
+ } = _ref87;
11759
11785
 
11760
11786
  var enforceOrder = (loc, modifier, before, after) => {
11761
11787
  if (modifier === before && modified[after]) {
@@ -11794,6 +11820,16 @@
11794
11820
  enforceOrder(startLoc, modifier, modifier, "readonly");
11795
11821
  modified.accessibility = modifier;
11796
11822
  }
11823
+ } else if (tsIsVarianceAnnotations(modifier)) {
11824
+ if (modified[modifier]) {
11825
+ this.raise(TSErrors.DuplicateModifier, {
11826
+ at: startLoc,
11827
+ modifier
11828
+ });
11829
+ }
11830
+
11831
+ modified[modifier] = true;
11832
+ enforceOrder(startLoc, modifier, "in", "out");
11797
11833
  } else {
11798
11834
  if (Object.hasOwnProperty.call(modified, modifier)) {
11799
11835
  this.raise(TSErrors.DuplicateModifier, {
@@ -11813,7 +11849,7 @@
11813
11849
  }
11814
11850
 
11815
11851
  if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
11816
- this.raise(TSErrors.InvalidModifierOnTypeMember, {
11852
+ this.raise(errorTemplate, {
11817
11853
  at: startLoc,
11818
11854
  modifier
11819
11855
  });
@@ -11990,24 +12026,48 @@
11990
12026
  node.exprName = this.tsParseEntityName();
11991
12027
  }
11992
12028
 
12029
+ if (!this.hasPrecedingLineBreak() && this.match(47)) {
12030
+ node.typeParameters = this.tsParseTypeArguments();
12031
+ }
12032
+
11993
12033
  return this.finishNode(node, "TSTypeQuery");
11994
12034
  }
11995
12035
 
12036
+ tsParseInOutModifiers(node) {
12037
+ this.tsParseModifiers({
12038
+ modified: node,
12039
+ allowedModifiers: ["in", "out"],
12040
+ disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
12041
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameter
12042
+ });
12043
+ }
12044
+
12045
+ tsParseNoneModifiers(node) {
12046
+ this.tsParseModifiers({
12047
+ modified: node,
12048
+ allowedModifiers: [],
12049
+ disallowedModifiers: ["in", "out"],
12050
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
12051
+ });
12052
+ }
12053
+
11996
12054
  tsParseTypeParameter() {
12055
+ var parseModifiers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.tsParseNoneModifiers.bind(this);
11997
12056
  var node = this.startNode();
12057
+ parseModifiers(node);
11998
12058
  node.name = this.tsParseTypeParameterName();
11999
12059
  node.constraint = this.tsEatThenParseType(81);
12000
12060
  node.default = this.tsEatThenParseType(29);
12001
12061
  return this.finishNode(node, "TSTypeParameter");
12002
12062
  }
12003
12063
 
12004
- tsTryParseTypeParameters() {
12064
+ tsTryParseTypeParameters(parseModifiers) {
12005
12065
  if (this.match(47)) {
12006
- return this.tsParseTypeParameters();
12066
+ return this.tsParseTypeParameters(parseModifiers);
12007
12067
  }
12008
12068
  }
12009
12069
 
12010
- tsParseTypeParameters() {
12070
+ tsParseTypeParameters(parseModifiers) {
12011
12071
  var node = this.startNode();
12012
12072
 
12013
12073
  if (this.match(47) || this.match(138)) {
@@ -12019,7 +12079,7 @@
12019
12079
  var refTrailingCommaPos = {
12020
12080
  value: -1
12021
12081
  };
12022
- node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
12082
+ node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
12023
12083
 
12024
12084
  if (node.params.length === 0) {
12025
12085
  this.raise(TSErrors.EmptyTypeParameters, {
@@ -12410,7 +12470,7 @@
12410
12470
  this.next();
12411
12471
  }
12412
12472
 
12413
- this.tsFillSignature(19, node);
12473
+ this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
12414
12474
  return this.finishNode(node, type);
12415
12475
  }
12416
12476
 
@@ -12579,13 +12639,24 @@
12579
12639
  this.expectContextual(112);
12580
12640
  var typeParameter = this.startNode();
12581
12641
  typeParameter.name = this.tsParseTypeParameterName();
12642
+ typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
12582
12643
  node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
12583
12644
  return this.finishNode(node, "TSInferType");
12584
12645
  }
12585
12646
 
12647
+ tsParseConstraintForInferType() {
12648
+ if (this.eat(81)) {
12649
+ var constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
12650
+
12651
+ if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
12652
+ return constraint;
12653
+ }
12654
+ }
12655
+ }
12656
+
12586
12657
  tsParseTypeOperatorOrHigher() {
12587
12658
  var isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
12588
- return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
12659
+ return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
12589
12660
  }
12590
12661
 
12591
12662
  tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
@@ -12787,17 +12858,17 @@
12787
12858
  assert(this.state.inType);
12788
12859
  var type = this.tsParseNonConditionalType();
12789
12860
 
12790
- if (this.hasPrecedingLineBreak() || !this.eat(81)) {
12861
+ if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
12791
12862
  return type;
12792
12863
  }
12793
12864
 
12794
12865
  var node = this.startNodeAtNode(type);
12795
12866
  node.checkType = type;
12796
- node.extendsType = this.tsParseNonConditionalType();
12867
+ node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
12797
12868
  this.expect(17);
12798
- node.trueType = this.tsParseType();
12869
+ node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
12799
12870
  this.expect(14);
12800
- node.falseType = this.tsParseType();
12871
+ node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
12801
12872
  return this.finishNode(node, "TSConditionalType");
12802
12873
  }
12803
12874
 
@@ -12838,7 +12909,16 @@
12838
12909
 
12839
12910
  tsParseHeritageClause(token) {
12840
12911
  var originalStartLoc = this.state.startLoc;
12841
- var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
12912
+ var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
12913
+ var node = this.startNode();
12914
+ node.expression = this.tsParseEntityName();
12915
+
12916
+ if (this.match(47)) {
12917
+ node.typeParameters = this.tsParseTypeArguments();
12918
+ }
12919
+
12920
+ return this.finishNode(node, "TSExpressionWithTypeArguments");
12921
+ });
12842
12922
 
12843
12923
  if (!delimitedList.length) {
12844
12924
  this.raise(TSErrors.EmptyHeritageClauseType, {
@@ -12850,17 +12930,6 @@
12850
12930
  return delimitedList;
12851
12931
  }
12852
12932
 
12853
- tsParseExpressionWithTypeArguments() {
12854
- var node = this.startNode();
12855
- node.expression = this.tsParseEntityName();
12856
-
12857
- if (this.match(47)) {
12858
- node.typeParameters = this.tsParseTypeArguments();
12859
- }
12860
-
12861
- return this.finishNode(node, "TSExpressionWithTypeArguments");
12862
- }
12863
-
12864
12933
  tsParseInterfaceDeclaration(node) {
12865
12934
  var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12866
12935
  if (this.hasFollowingLineBreak()) return null;
@@ -12877,7 +12946,7 @@
12877
12946
  });
12878
12947
  }
12879
12948
 
12880
- node.typeParameters = this.tsTryParseTypeParameters();
12949
+ node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
12881
12950
 
12882
12951
  if (this.eat(81)) {
12883
12952
  node.extends = this.tsParseHeritageClause("extends");
@@ -12893,7 +12962,7 @@
12893
12962
  node.id = this.parseIdentifier();
12894
12963
  this.checkIdentifier(node.id, BIND_TS_TYPE);
12895
12964
  node.typeAnnotation = this.tsInType(() => {
12896
- node.typeParameters = this.tsTryParseTypeParameters();
12965
+ node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
12897
12966
  this.expect(29);
12898
12967
 
12899
12968
  if (this.isContextual(111) && this.lookahead().type !== 16) {
@@ -12931,6 +13000,28 @@
12931
13000
  }
12932
13001
  }
12933
13002
 
13003
+ tsInDisallowConditionalTypesContext(cb) {
13004
+ var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
13005
+ this.state.inDisallowConditionalTypesContext = true;
13006
+
13007
+ try {
13008
+ return cb();
13009
+ } finally {
13010
+ this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
13011
+ }
13012
+ }
13013
+
13014
+ tsInAllowConditionalTypesContext(cb) {
13015
+ var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
13016
+ this.state.inDisallowConditionalTypesContext = false;
13017
+
13018
+ try {
13019
+ return cb();
13020
+ } finally {
13021
+ this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
13022
+ }
13023
+ }
13024
+
12934
13025
  tsEatThenParseType(token) {
12935
13026
  return !this.match(token) ? undefined : this.tsNextThenParseType();
12936
13027
  }
@@ -13450,35 +13541,44 @@
13450
13541
  }
13451
13542
  }
13452
13543
 
13453
- var node = this.startNodeAt(startPos, startLoc);
13454
- node.callee = base;
13455
13544
  var typeArguments = this.tsParseTypeArgumentsInExpression();
13545
+ if (!typeArguments) throw this.unexpected();
13456
13546
 
13457
- if (typeArguments) {
13458
- if (isOptionalCall && !this.match(10)) {
13459
- missingParenErrorLoc = this.state.curPosition();
13460
- this.unexpected();
13461
- }
13547
+ if (isOptionalCall && !this.match(10)) {
13548
+ missingParenErrorLoc = this.state.curPosition();
13549
+ throw this.unexpected();
13550
+ }
13462
13551
 
13463
- if (!noCalls && this.eat(10)) {
13464
- node.arguments = this.parseCallExpressionArguments(11, false);
13465
- this.tsCheckForInvalidTypeCasts(node.arguments);
13466
- node.typeParameters = typeArguments;
13552
+ if (tokenIsTemplate(this.state.type)) {
13553
+ var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
13467
13554
 
13468
- if (state.optionalChainMember) {
13469
- node.optional = isOptionalCall;
13470
- }
13555
+ _result.typeParameters = typeArguments;
13556
+ return _result;
13557
+ }
13558
+
13559
+ if (!noCalls && this.eat(10)) {
13560
+ var _node9 = this.startNodeAt(startPos, startLoc);
13471
13561
 
13472
- return this.finishCallExpression(node, state.optionalChainMember);
13473
- } else if (tokenIsTemplate(this.state.type)) {
13474
- var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
13562
+ _node9.callee = base;
13563
+ _node9.arguments = this.parseCallExpressionArguments(11, false);
13564
+ this.tsCheckForInvalidTypeCasts(_node9.arguments);
13565
+ _node9.typeParameters = typeArguments;
13475
13566
 
13476
- _result.typeParameters = typeArguments;
13477
- return _result;
13567
+ if (state.optionalChainMember) {
13568
+ _node9.optional = isOptionalCall;
13478
13569
  }
13570
+
13571
+ return this.finishCallExpression(_node9, state.optionalChainMember);
13479
13572
  }
13480
13573
 
13481
- this.unexpected();
13574
+ if (tsTokenCanStartExpression(this.state.type) && this.state.type !== 10) {
13575
+ throw this.unexpected();
13576
+ }
13577
+
13578
+ var node = this.startNodeAt(startPos, startLoc);
13579
+ node.expression = base;
13580
+ node.typeParameters = typeArguments;
13581
+ return this.finishNode(node, "TSInstantiationExpression");
13482
13582
  });
13483
13583
 
13484
13584
  if (missingParenErrorLoc) {
@@ -13491,20 +13591,18 @@
13491
13591
  return super.parseSubscript(base, startPos, startLoc, noCalls, state);
13492
13592
  }
13493
13593
 
13494
- parseNewArguments(node) {
13495
- if (this.match(47) || this.match(51)) {
13496
- var typeParameters = this.tsTryParseAndCatch(() => {
13497
- var args = this.tsParseTypeArgumentsInExpression();
13498
- if (!this.match(10)) this.unexpected();
13499
- return args;
13500
- });
13594
+ parseNewCallee(node) {
13595
+ var _callee$extra;
13501
13596
 
13502
- if (typeParameters) {
13503
- node.typeParameters = typeParameters;
13504
- }
13505
- }
13597
+ super.parseNewCallee(node);
13598
+ var {
13599
+ callee
13600
+ } = node;
13506
13601
 
13507
- super.parseNewArguments(node);
13602
+ if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
13603
+ node.typeParameters = callee.typeParameters;
13604
+ node.callee = callee.expression;
13605
+ }
13508
13606
  }
13509
13607
 
13510
13608
  parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
@@ -13692,7 +13790,9 @@
13692
13790
  this.tsParseModifiers({
13693
13791
  modified: member,
13694
13792
  allowedModifiers: modifiers,
13695
- stopOnStartOfClassStaticBlock: true
13793
+ disallowedModifiers: ["in", "out"],
13794
+ stopOnStartOfClassStaticBlock: true,
13795
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
13696
13796
  });
13697
13797
 
13698
13798
  var callParseClassMemberWithIsStatic = () => {
@@ -13871,7 +13971,7 @@
13871
13971
  }
13872
13972
 
13873
13973
  super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS);
13874
- var typeParameters = this.tsTryParseTypeParameters();
13974
+ var typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
13875
13975
  if (typeParameters) node.typeParameters = typeParameters;
13876
13976
  }
13877
13977
 
@@ -13977,8 +14077,8 @@
13977
14077
  var typeParameters = this.tsTryParseTypeParameters();
13978
14078
  if (typeParameters) prop.typeParameters = typeParameters;
13979
14079
 
13980
- for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
13981
- args[_key5 - 1] = arguments[_key5];
14080
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
14081
+ args[_key4 - 1] = arguments[_key4];
13982
14082
  }
13983
14083
 
13984
14084
  super.parseObjPropValue(prop, ...args);
@@ -14014,8 +14114,8 @@
14014
14114
  }
14015
14115
 
14016
14116
  parseMaybeAssign() {
14017
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
14018
- args[_key6] = arguments[_key6];
14117
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
14118
+ args[_key5] = arguments[_key5];
14019
14119
  }
14020
14120
 
14021
14121
  var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2, _jsx4, _typeCast3;
@@ -14042,10 +14142,10 @@
14042
14142
  return super.parseMaybeAssign(...args);
14043
14143
  }
14044
14144
 
14145
+ if (!state || state === this.state) state = this.state.clone();
14045
14146
  var typeParameters;
14046
- state = state || this.state.clone();
14047
14147
  var arrow = this.tryParse(abort => {
14048
- var _expr$extra, _typeParameters, _expr$typeParameters$;
14148
+ var _expr$extra, _typeParameters;
14049
14149
 
14050
14150
  typeParameters = this.tsParseTypeParameters();
14051
14151
  var expr = super.parseMaybeAssign(...args);
@@ -14059,12 +14159,6 @@
14059
14159
  }
14060
14160
 
14061
14161
  expr.typeParameters = typeParameters;
14062
-
14063
- if (this.hasPlugin("jsx") && expr.typeParameters.params.length === 1 && !((_expr$typeParameters$ = expr.typeParameters.extra) != null && _expr$typeParameters$.trailingComma)) {
14064
- var parameter = expr.typeParameters.params[0];
14065
- if (!parameter.constraint) ;
14066
- }
14067
-
14068
14162
  return expr;
14069
14163
  }, state);
14070
14164
 
@@ -14171,23 +14265,33 @@
14171
14265
  var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
14172
14266
 
14173
14267
  switch (node.type) {
14174
- case "TSTypeCastExpression":
14175
- return super.toAssignable(this.typeCastToParameter(node), isLHS);
14176
-
14177
- case "TSParameterProperty":
14178
- return super.toAssignable(node, isLHS);
14179
-
14180
14268
  case "ParenthesizedExpression":
14181
- return this.toAssignableParenthesizedExpression(node, isLHS);
14269
+ this.toAssignableParenthesizedExpression(node, isLHS);
14270
+ break;
14182
14271
 
14183
14272
  case "TSAsExpression":
14184
14273
  case "TSNonNullExpression":
14185
14274
  case "TSTypeAssertion":
14186
- node.expression = this.toAssignable(node.expression, isLHS);
14187
- return node;
14275
+ if (isLHS) {
14276
+ this.expressionScope.recordArrowParemeterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
14277
+ at: node
14278
+ });
14279
+ } else {
14280
+ this.raise(TSErrors.UnexpectedTypeCastInParameter, {
14281
+ at: node
14282
+ });
14283
+ }
14284
+
14285
+ this.toAssignable(node.expression, isLHS);
14286
+ break;
14287
+
14288
+ case "AssignmentExpression":
14289
+ if (!isLHS && node.left.type === "TSTypeCastExpression") {
14290
+ node.left = this.typeCastToParameter(node.left);
14291
+ }
14188
14292
 
14189
14293
  default:
14190
- return super.toAssignable(node, isLHS);
14294
+ super.toAssignable(node, isLHS);
14191
14295
  }
14192
14296
  }
14193
14297
 
@@ -14197,22 +14301,35 @@
14197
14301
  case "TSNonNullExpression":
14198
14302
  case "TSTypeAssertion":
14199
14303
  case "ParenthesizedExpression":
14200
- node.expression = this.toAssignable(node.expression, isLHS);
14201
- return node;
14304
+ this.toAssignable(node.expression, isLHS);
14305
+ break;
14306
+
14307
+ default:
14308
+ super.toAssignable(node, isLHS);
14309
+ }
14310
+ }
14311
+
14312
+ checkToRestConversion(node, allowPattern) {
14313
+ switch (node.type) {
14314
+ case "TSAsExpression":
14315
+ case "TSTypeAssertion":
14316
+ case "TSNonNullExpression":
14317
+ this.checkToRestConversion(node.expression, false);
14318
+ break;
14202
14319
 
14203
14320
  default:
14204
- return super.toAssignable(node, isLHS);
14321
+ super.checkToRestConversion(node, allowPattern);
14205
14322
  }
14206
14323
  }
14207
14324
 
14208
- isValidLVal(type, isParenthesized, binding) {
14325
+ isValidLVal(type, isUnparenthesizedInAssign, binding) {
14209
14326
  return getOwn$1({
14210
14327
  TSTypeCastExpression: true,
14211
14328
  TSParameterProperty: "parameter",
14212
14329
  TSNonNullExpression: "expression",
14213
- TSAsExpression: (binding !== BIND_NONE || isParenthesized) && ["expression", true],
14214
- TSTypeAssertion: (binding !== BIND_NONE || isParenthesized) && ["expression", true]
14215
- }, type) || super.isValidLVal(type, isParenthesized, binding);
14330
+ TSAsExpression: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true],
14331
+ TSTypeAssertion: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true]
14332
+ }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
14216
14333
  }
14217
14334
 
14218
14335
  parseBindingAtom() {
@@ -14315,28 +14432,13 @@
14315
14432
  toAssignableList(exprList) {
14316
14433
  for (var i = 0; i < exprList.length; i++) {
14317
14434
  var expr = exprList[i];
14318
- if (!expr) continue;
14319
14435
 
14320
- switch (expr.type) {
14321
- case "TSTypeCastExpression":
14322
- exprList[i] = this.typeCastToParameter(expr);
14323
- break;
14324
-
14325
- case "TSAsExpression":
14326
- case "TSTypeAssertion":
14327
- if (!this.state.maybeInArrowParameters) {
14328
- exprList[i] = this.typeCastToParameter(expr);
14329
- } else {
14330
- this.raise(TSErrors.UnexpectedTypeCastInParameter, {
14331
- at: expr
14332
- });
14333
- }
14334
-
14335
- break;
14436
+ if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
14437
+ exprList[i] = this.typeCastToParameter(expr);
14336
14438
  }
14337
14439
  }
14338
14440
 
14339
- return super.toAssignableList(...arguments);
14441
+ super.toAssignableList(...arguments);
14340
14442
  }
14341
14443
 
14342
14444
  typeCastToParameter(node) {
@@ -14406,8 +14508,8 @@
14406
14508
  this.state.inAbstractClass = !!node.abstract;
14407
14509
 
14408
14510
  try {
14409
- for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
14410
- args[_key7 - 1] = arguments[_key7];
14511
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
14512
+ args[_key6 - 1] = arguments[_key6];
14411
14513
  }
14412
14514
 
14413
14515
  return super.parseClass(node, ...args);
@@ -14531,7 +14633,16 @@
14531
14633
  }
14532
14634
  } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14533
14635
  hasTypeSpecifier = true;
14534
- leftOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
14636
+
14637
+ if (isImport) {
14638
+ leftOfAs = this.parseIdentifier(true);
14639
+
14640
+ if (!this.isContextual(93)) {
14641
+ this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
14642
+ }
14643
+ } else {
14644
+ leftOfAs = this.parseModuleExportName();
14645
+ }
14535
14646
  }
14536
14647
 
14537
14648
  if (hasTypeSpecifier && isInTypeOnlyImportExport) {
@@ -14630,8 +14741,8 @@
14630
14741
  }
14631
14742
 
14632
14743
  isValidLVal(type) {
14633
- for (var _len8 = arguments.length, rest = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
14634
- rest[_key8 - 1] = arguments[_key8];
14744
+ for (var _len7 = arguments.length, rest = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
14745
+ rest[_key7 - 1] = arguments[_key7];
14635
14746
  }
14636
14747
 
14637
14748
  return type === "Placeholder" || super.isValidLVal(type, ...rest);
@@ -14640,10 +14751,9 @@
14640
14751
  toAssignable(node) {
14641
14752
  if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
14642
14753
  node.expectedNode = "Pattern";
14643
- return node;
14754
+ } else {
14755
+ super.toAssignable(...arguments);
14644
14756
  }
14645
-
14646
- return super.toAssignable(...arguments);
14647
14757
  }
14648
14758
 
14649
14759
  isLet(context) {
@@ -14955,9 +15065,9 @@
14955
15065
  throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
14956
15066
  }
14957
15067
 
14958
- var moduleAttributesVerionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
15068
+ var moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
14959
15069
 
14960
- if (moduleAttributesVerionPluginOption !== "may-2020") {
15070
+ if (moduleAttributesVersionPluginOption !== "may-2020") {
14961
15071
  throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
14962
15072
  }
14963
15073
  }
@@ -15031,7 +15141,7 @@
15031
15141
 
15032
15142
  if (isLHS) {
15033
15143
  if (parenthesized.type === "Identifier") {
15034
- this.expressionScope.recordParenthesizedIdentifierError({
15144
+ this.expressionScope.recordArrowParemeterBindingError(Errors.InvalidParenthesizedAssignment, {
15035
15145
  at: node
15036
15146
  });
15037
15147
  } else if (parenthesized.type !== "MemberExpression") {
@@ -15090,11 +15200,7 @@
15090
15200
 
15091
15201
  case "SpreadElement":
15092
15202
  {
15093
- this.checkToRestConversion(node);
15094
- node.type = "RestElement";
15095
- var arg = node.argument;
15096
- this.toAssignable(arg, isLHS);
15097
- break;
15203
+ throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
15098
15204
  }
15099
15205
 
15100
15206
  case "ArrayExpression":
@@ -15118,8 +15224,6 @@
15118
15224
  this.toAssignable(parenthesized, isLHS);
15119
15225
  break;
15120
15226
  }
15121
-
15122
- return node;
15123
15227
  }
15124
15228
 
15125
15229
  toAssignableObjectExpressionProp(prop, isLast, isLHS) {
@@ -15127,58 +15231,50 @@
15127
15231
  this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, {
15128
15232
  at: prop.key
15129
15233
  });
15130
- } else if (prop.type === "SpreadElement" && !isLast) {
15131
- this.raise(Errors.RestTrailingComma, {
15132
- at: prop
15133
- });
15234
+ } else if (prop.type === "SpreadElement") {
15235
+ prop.type = "RestElement";
15236
+ var arg = prop.argument;
15237
+ this.checkToRestConversion(arg, false);
15238
+ this.toAssignable(arg, isLHS);
15239
+
15240
+ if (!isLast) {
15241
+ this.raise(Errors.RestTrailingComma, {
15242
+ at: prop
15243
+ });
15244
+ }
15134
15245
  } else {
15135
15246
  this.toAssignable(prop, isLHS);
15136
15247
  }
15137
15248
  }
15138
15249
 
15139
15250
  toAssignableList(exprList, trailingCommaLoc, isLHS) {
15140
- var end = exprList.length;
15141
-
15142
- if (end) {
15143
- var last = exprList[end - 1];
15144
-
15145
- if ((last == null ? void 0 : last.type) === "RestElement") {
15146
- --end;
15147
- } else if ((last == null ? void 0 : last.type) === "SpreadElement") {
15148
- last.type = "RestElement";
15149
- var arg = last.argument;
15150
- this.toAssignable(arg, isLHS);
15151
- arg = unwrapParenthesizedExpression(arg);
15152
-
15153
- if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
15154
- this.unexpected(arg.start);
15155
- }
15251
+ var end = exprList.length - 1;
15156
15252
 
15157
- if (trailingCommaLoc) {
15158
- this.raise(Errors.RestTrailingComma, {
15159
- at: trailingCommaLoc
15160
- });
15161
- }
15162
-
15163
- --end;
15164
- }
15165
- }
15166
-
15167
- for (var i = 0; i < end; i++) {
15253
+ for (var i = 0; i <= end; i++) {
15168
15254
  var elt = exprList[i];
15255
+ if (!elt) continue;
15169
15256
 
15170
- if (elt) {
15257
+ if (elt.type === "SpreadElement") {
15258
+ elt.type = "RestElement";
15259
+ var arg = elt.argument;
15260
+ this.checkToRestConversion(arg, true);
15261
+ this.toAssignable(arg, isLHS);
15262
+ } else {
15171
15263
  this.toAssignable(elt, isLHS);
15264
+ }
15172
15265
 
15173
- if (elt.type === "RestElement") {
15266
+ if (elt.type === "RestElement") {
15267
+ if (i < end) {
15174
15268
  this.raise(Errors.RestTrailingComma, {
15175
15269
  at: elt
15176
15270
  });
15271
+ } else if (trailingCommaLoc) {
15272
+ this.raise(Errors.RestTrailingComma, {
15273
+ at: trailingCommaLoc
15274
+ });
15177
15275
  }
15178
15276
  }
15179
15277
  }
15180
-
15181
- return exprList;
15182
15278
  }
15183
15279
 
15184
15280
  isAssignable(node, isBinding) {
@@ -15368,7 +15464,7 @@
15368
15464
  return this.finishNode(node, "AssignmentPattern");
15369
15465
  }
15370
15466
 
15371
- isValidLVal(type, isParenthesized, binding) {
15467
+ isValidLVal(type, isUnparenthesizedInAssign, binding) {
15372
15468
  return getOwn({
15373
15469
  AssignmentPattern: "left",
15374
15470
  RestElement: "argument",
@@ -15379,7 +15475,7 @@
15379
15475
  }, type);
15380
15476
  }
15381
15477
 
15382
- checkLVal(expression, _ref86) {
15478
+ checkLVal(expression, _ref88) {
15383
15479
  var {
15384
15480
  in: ancestor,
15385
15481
  binding = BIND_NONE,
@@ -15387,7 +15483,7 @@
15387
15483
  strictModeChanged = false,
15388
15484
  allowingSloppyLetBinding = !(binding & BIND_SCOPE_LEXICAL),
15389
15485
  hasParenthesizedAncestor = false
15390
- } = _ref86;
15486
+ } = _ref88;
15391
15487
 
15392
15488
  var _expression$extra;
15393
15489
 
@@ -15423,7 +15519,7 @@
15423
15519
  return;
15424
15520
  }
15425
15521
 
15426
- var validity = this.isValidLVal(expression.type, hasParenthesizedAncestor || ((_expression$extra = expression.extra) == null ? void 0 : _expression$extra.parenthesized), binding);
15522
+ var validity = this.isValidLVal(expression.type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
15427
15523
  if (validity === true) return;
15428
15524
 
15429
15525
  if (validity === false) {
@@ -15490,11 +15586,24 @@
15490
15586
  this.scope.declareName(identifier.name, binding, identifier.loc.start);
15491
15587
  }
15492
15588
 
15493
- checkToRestConversion(node) {
15494
- if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
15495
- this.raise(Errors.InvalidRestAssignmentPattern, {
15496
- at: node.argument
15497
- });
15589
+ checkToRestConversion(node, allowPattern) {
15590
+ switch (node.type) {
15591
+ case "ParenthesizedExpression":
15592
+ this.checkToRestConversion(node.expression, allowPattern);
15593
+ break;
15594
+
15595
+ case "Identifier":
15596
+ case "MemberExpression":
15597
+ break;
15598
+
15599
+ case "ArrayExpression":
15600
+ case "ObjectExpression":
15601
+ if (allowPattern) break;
15602
+
15603
+ default:
15604
+ this.raise(Errors.InvalidRestAssignmentPattern, {
15605
+ at: node
15606
+ });
15498
15607
  }
15499
15608
  }
15500
15609
 
@@ -15655,7 +15764,8 @@
15655
15764
  node.operator = operator;
15656
15765
 
15657
15766
  if (this.match(29)) {
15658
- node.left = this.toAssignable(left, true);
15767
+ this.toAssignable(left, true);
15768
+ node.left = left;
15659
15769
 
15660
15770
  if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startPos) {
15661
15771
  refExpressionErrors.doubleProtoLoc = null;
@@ -15955,14 +16065,14 @@
15955
16065
  if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
15956
16066
 
15957
16067
  while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
15958
- var _node9 = this.startNodeAt(startPos, startLoc);
16068
+ var _node10 = this.startNodeAt(startPos, startLoc);
15959
16069
 
15960
- _node9.operator = this.state.value;
15961
- _node9.prefix = false;
15962
- _node9.argument = expr;
16070
+ _node10.operator = this.state.value;
16071
+ _node10.prefix = false;
16072
+ _node10.argument = expr;
15963
16073
  this.next();
15964
16074
  this.checkLVal(expr, {
15965
- in: expr = this.finishNode(_node9, "UpdateExpression")
16075
+ in: expr = this.finishNode(_node10, "UpdateExpression")
15966
16076
  });
15967
16077
  }
15968
16078
 
@@ -16822,6 +16932,20 @@
16822
16932
  }
16823
16933
 
16824
16934
  parseNew(node) {
16935
+ this.parseNewCallee(node);
16936
+
16937
+ if (this.eat(10)) {
16938
+ var args = this.parseExprList(11);
16939
+ this.toReferencedList(args);
16940
+ node.arguments = args;
16941
+ } else {
16942
+ node.arguments = [];
16943
+ }
16944
+
16945
+ return this.finishNode(node, "NewExpression");
16946
+ }
16947
+
16948
+ parseNewCallee(node) {
16825
16949
  node.callee = this.parseNoCallExpr();
16826
16950
 
16827
16951
  if (node.callee.type === "Import") {
@@ -16837,19 +16961,6 @@
16837
16961
  at: this.state.startLoc
16838
16962
  });
16839
16963
  }
16840
-
16841
- this.parseNewArguments(node);
16842
- return this.finishNode(node, "NewExpression");
16843
- }
16844
-
16845
- parseNewArguments(node) {
16846
- if (this.eat(10)) {
16847
- var args = this.parseExprList(11);
16848
- this.toReferencedList(args);
16849
- node.arguments = args;
16850
- } else {
16851
- node.arguments = [];
16852
- }
16853
16964
  }
16854
16965
 
16855
16966
  parseTemplateElement(isTagged) {
@@ -17256,7 +17367,8 @@
17256
17367
  }
17257
17368
 
17258
17369
  setArrowFunctionParameters(node, params, trailingCommaLoc) {
17259
- node.params = this.toAssignableList(params, trailingCommaLoc, false);
17370
+ this.toAssignableList(params, trailingCommaLoc, false);
17371
+ node.params = params;
17260
17372
  }
17261
17373
 
17262
17374
  parseFunctionBodyAndFinish(node, type) {
@@ -18197,12 +18309,12 @@
18197
18309
  expr = this.parseIdentifier(false);
18198
18310
 
18199
18311
  while (this.eat(16)) {
18200
- var _node10 = this.startNodeAt(startPos, startLoc);
18312
+ var _node11 = this.startNodeAt(startPos, startLoc);
18201
18313
 
18202
- _node10.object = expr;
18203
- _node10.property = this.parseIdentifier(true);
18204
- _node10.computed = false;
18205
- expr = this.finishNode(_node10, "MemberExpression");
18314
+ _node11.object = expr;
18315
+ _node11.property = this.parseIdentifier(true);
18316
+ _node11.computed = false;
18317
+ expr = this.finishNode(_node11, "MemberExpression");
18206
18318
  }
18207
18319
  }
18208
18320