@next-core/brick-utils 2.37.25 → 2.38.1

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
@@ -2,8 +2,8 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
2
2
  import { uniq, get, cloneDeep, set, isEmpty, escapeRegExp } from 'lodash';
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
5
- import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
6
5
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
7
7
  import { processPipes, utils } from '@next-core/pipes';
8
8
  export { pipes } from '@next-core/pipes';
9
9
  import yaml from 'js-yaml';
@@ -3272,6 +3272,7 @@ var StandardErrors = _ => ({
3272
3272
  }),
3273
3273
  ImportCallNotNewExpression: _("Cannot use new with import(...)."),
3274
3274
  ImportCallSpreadArgument: _("`...` is not allowed in `import()`."),
3275
+ ImportJSONBindingNotDefault: _("A JSON module can only be imported with `default`."),
3275
3276
  IncompatibleRegExpUVFlags: _("The 'u' and 'v' regular expression flags cannot be enabled at the same time."),
3276
3277
  InvalidBigIntLiteral: _("Invalid BigIntLiteral."),
3277
3278
  InvalidCodePoint: _("Code point out of bounds."),
@@ -3608,8 +3609,8 @@ var toUnenumerable = (object, key) => defineProperty(object, key, {
3608
3609
  });
3609
3610
 
3610
3611
  function toESTreeLocation(node) {
3611
- toUnenumerable(node.loc.start, "index");
3612
- toUnenumerable(node.loc.end, "index");
3612
+ node.loc.start && toUnenumerable(node.loc.start, "index");
3613
+ node.loc.end && toUnenumerable(node.loc.end, "index");
3613
3614
  return node;
3614
3615
  }
3615
3616
 
@@ -3883,10 +3884,9 @@ var estree = superClass => class extends superClass {
3883
3884
  }
3884
3885
 
3885
3886
  this.toAssignable(value, isLHS);
3886
- return node;
3887
+ } else {
3888
+ super.toAssignable(node, isLHS);
3887
3889
  }
3888
-
3889
- return super.toAssignable(node, isLHS);
3890
3890
  }
3891
3891
 
3892
3892
  toAssignableObjectExpressionProp(prop) {
@@ -3899,11 +3899,7 @@ var estree = superClass => class extends superClass {
3899
3899
  at: prop.key
3900
3900
  });
3901
3901
  } else {
3902
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
3903
- args[_key3 - 1] = arguments[_key3];
3904
- }
3905
-
3906
- super.toAssignableObjectExpressionProp(prop, ...args);
3902
+ super.toAssignableObjectExpressionProp(...arguments);
3907
3903
  }
3908
3904
  }
3909
3905
 
@@ -4000,6 +3996,11 @@ var estree = superClass => class extends superClass {
4000
3996
  return toESTreeLocation(super.finishNodeAt(node, type, endLoc));
4001
3997
  }
4002
3998
 
3999
+ resetStartLocation(node, start, startLoc) {
4000
+ super.resetStartLocation(node, start, startLoc);
4001
+ toESTreeLocation(node);
4002
+ }
4003
+
4003
4004
  resetEndLocation(node) {
4004
4005
  var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
4005
4006
  super.resetEndLocation(node, endLoc);
@@ -4147,9 +4148,7 @@ var tt = {
4147
4148
  beforeExpr,
4148
4149
  startsExpr
4149
4150
  }),
4150
- braceR: createToken("}", {
4151
- beforeExpr
4152
- }),
4151
+ braceR: createToken("}"),
4153
4152
  braceBarR: createToken("|}"),
4154
4153
  parenL: createToken("(", {
4155
4154
  beforeExpr,
@@ -5039,6 +5038,7 @@ class State {
5039
5038
  this.hasFlowComment = false;
5040
5039
  this.isAmbientContext = false;
5041
5040
  this.inAbstractClass = false;
5041
+ this.inDisallowConditionalTypesContext = false;
5042
5042
  this.topicContext = {
5043
5043
  maxNumOfResolvableTopics: 0,
5044
5044
  maxTopicIndex: null
@@ -7051,7 +7051,7 @@ class ExpressionScopeHandler {
7051
7051
  this.parser.raise(toParseError, origin);
7052
7052
  }
7053
7053
 
7054
- recordParenthesizedIdentifierError(_ref45) {
7054
+ recordArrowParemeterBindingError(error, _ref45) {
7055
7055
  var {
7056
7056
  at: node
7057
7057
  } = _ref45;
@@ -7064,9 +7064,9 @@ class ExpressionScopeHandler {
7064
7064
  };
7065
7065
 
7066
7066
  if (scope.isCertainlyParameterDeclaration()) {
7067
- this.parser.raise(Errors.InvalidParenthesizedAssignment, origin);
7067
+ this.parser.raise(error, origin);
7068
7068
  } else if (scope.canBeArrowParameterDeclaration()) {
7069
- scope.recordDeclarationError(Errors.InvalidParenthesizedAssignment, origin);
7069
+ scope.recordDeclarationError(error, origin);
7070
7070
  } else {
7071
7071
  return;
7072
7072
  }
@@ -9517,11 +9517,11 @@ var flow = superClass => class extends superClass {
9517
9517
  toAssignable(node) {
9518
9518
  var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9519
9519
 
9520
- if (node.type === "TypeCastExpression") {
9521
- return super.toAssignable(this.typeCastToParameter(node), isLHS);
9522
- } else {
9523
- return super.toAssignable(node, isLHS);
9520
+ if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") {
9521
+ node.left = this.typeCastToParameter(node.left);
9524
9522
  }
9523
+
9524
+ super.toAssignable(...arguments);
9525
9525
  }
9526
9526
 
9527
9527
  toAssignableList(exprList, trailingCommaLoc, isLHS) {
@@ -9533,7 +9533,7 @@ var flow = superClass => class extends superClass {
9533
9533
  }
9534
9534
  }
9535
9535
 
9536
- return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
9536
+ super.toAssignableList(exprList, trailingCommaLoc, isLHS);
9537
9537
  }
9538
9538
 
9539
9539
  toReferencedList(exprList, isParenthesizedExpr) {
@@ -9563,8 +9563,8 @@ var flow = superClass => class extends superClass {
9563
9563
  }
9564
9564
 
9565
9565
  isValidLVal(type) {
9566
- for (var _len4 = arguments.length, rest = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
9567
- rest[_key4 - 1] = arguments[_key4];
9566
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
9567
+ rest[_key3 - 1] = arguments[_key3];
9568
9568
  }
9569
9569
 
9570
9570
  return type === "TypeCastExpression" || super.isValidLVal(type, ...rest);
@@ -10113,7 +10113,8 @@ var flow = superClass => class extends superClass {
10113
10113
  return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState);
10114
10114
  }
10115
10115
 
10116
- parseNewArguments(node) {
10116
+ parseNewCallee(node) {
10117
+ super.parseNewCallee(node);
10117
10118
  var targs = null;
10118
10119
 
10119
10120
  if (this.shouldParseTypes() && this.match(47)) {
@@ -10121,7 +10122,6 @@ var flow = superClass => class extends superClass {
10121
10122
  }
10122
10123
 
10123
10124
  node.typeArguments = targs;
10124
- super.parseNewArguments(node);
10125
10125
  }
10126
10126
 
10127
10127
  parseAsyncArrowWithTypeParameters(startPos, startLoc) {
@@ -11194,6 +11194,7 @@ var jsx = superClass => class extends superClass {
11194
11194
  this.next();
11195
11195
  node.expression = this.parseExpression();
11196
11196
  this.setContext(types.j_oTag);
11197
+ this.state.canStartJSXElement = true;
11197
11198
  this.expect(8);
11198
11199
  return this.finishNode(node, "JSXSpreadChild");
11199
11200
  }
@@ -11207,6 +11208,7 @@ var jsx = superClass => class extends superClass {
11207
11208
  }
11208
11209
 
11209
11210
  this.setContext(previousContext);
11211
+ this.state.canStartJSXElement = true;
11210
11212
  this.expect(8);
11211
11213
  return this.finishNode(node, "JSXExpressionContainer");
11212
11214
  }
@@ -11220,6 +11222,7 @@ var jsx = superClass => class extends superClass {
11220
11222
  this.expect(21);
11221
11223
  node.argument = this.parseMaybeAssignAllowIn();
11222
11224
  this.setContext(types.j_oTag);
11225
+ this.state.canStartJSXElement = true;
11223
11226
  this.expect(8);
11224
11227
  return this.finishNode(node, "JSXSpreadAttribute");
11225
11228
  }
@@ -11232,8 +11235,7 @@ var jsx = superClass => class extends superClass {
11232
11235
  jsxParseOpeningElementAt(startPos, startLoc) {
11233
11236
  var node = this.startNodeAt(startPos, startLoc);
11234
11237
 
11235
- if (this.match(139)) {
11236
- this.expect(139);
11238
+ if (this.eat(139)) {
11237
11239
  return this.finishNode(node, "JSXOpeningFragment");
11238
11240
  }
11239
11241
 
@@ -11257,8 +11259,7 @@ var jsx = superClass => class extends superClass {
11257
11259
  jsxParseClosingElementAt(startPos, startLoc) {
11258
11260
  var node = this.startNodeAt(startPos, startLoc);
11259
11261
 
11260
- if (this.match(139)) {
11261
- this.expect(139);
11262
+ if (this.eat(139)) {
11262
11263
  return this.finishNode(node, "JSXClosingFragment");
11263
11264
  }
11264
11265
 
@@ -11614,12 +11615,25 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11614
11615
  } = _ref80;
11615
11616
  return "'".concat(modifier, "' modifier cannot appear on a type member.");
11616
11617
  }),
11617
- InvalidModifiersOrder: _(_ref81 => {
11618
+ InvalidModifierOnTypeParameter: _(_ref81 => {
11618
11619
  var {
11619
- orderedModifiers
11620
+ modifier
11620
11621
  } = _ref81;
11622
+ return "'".concat(modifier, "' modifier cannot appear on a type parameter.");
11623
+ }),
11624
+ InvalidModifierOnTypeParameterPositions: _(_ref82 => {
11625
+ var {
11626
+ modifier
11627
+ } = _ref82;
11628
+ return "'".concat(modifier, "' modifier can only appear on a type parameter of a class, interface or type alias.");
11629
+ }),
11630
+ InvalidModifiersOrder: _(_ref83 => {
11631
+ var {
11632
+ orderedModifiers
11633
+ } = _ref83;
11621
11634
  return "'".concat(orderedModifiers[0], "' modifier must precede '").concat(orderedModifiers[1], "' modifier.");
11622
11635
  }),
11636
+ InvalidPropertyAccessAfterInstantiationExpression: _("Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments."),
11623
11637
  InvalidTupleMemberLabel: _("Tuple members must be labeled with a simple identifier."),
11624
11638
  MissingInterfaceName: _("'interface' declarations must be followed by an identifier."),
11625
11639
  MixedLabeledAndUnlabeledElements: _("Tuple members must all have names or all not have names."),
@@ -11629,10 +11643,10 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11629
11643
  OverrideNotInSubClass: _("This member cannot have an 'override' modifier because its containing class does not extend another class."),
11630
11644
  PatternIsOptional: _("A binding pattern parameter cannot be optional in an implementation signature."),
11631
11645
  PrivateElementHasAbstract: _("Private elements cannot have the 'abstract' modifier."),
11632
- PrivateElementHasAccessibility: _(_ref82 => {
11646
+ PrivateElementHasAccessibility: _(_ref84 => {
11633
11647
  var {
11634
11648
  modifier
11635
- } = _ref82;
11649
+ } = _ref84;
11636
11650
  return "Private elements cannot have an accessibility modifier ('".concat(modifier, "').");
11637
11651
  }),
11638
11652
  ReadonlyForMethodSignature: _("'readonly' modifier can only appear on a property declaration or index signature."),
@@ -11641,10 +11655,10 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11641
11655
  SetAccesorCannotHaveOptionalParameter: _("A 'set' accessor cannot have an optional parameter."),
11642
11656
  SetAccesorCannotHaveRestParameter: _("A 'set' accessor cannot have rest parameter."),
11643
11657
  SetAccesorCannotHaveReturnType: _("A 'set' accessor cannot have a return type annotation."),
11644
- SingleTypeParameterWithoutTrailingComma: _(_ref83 => {
11658
+ SingleTypeParameterWithoutTrailingComma: _(_ref85 => {
11645
11659
  var {
11646
11660
  typeParameterName
11647
- } = _ref83;
11661
+ } = _ref85;
11648
11662
  return "Single type parameter ".concat(typeParameterName, " should have a trailing comma. Example usage: <").concat(typeParameterName, ",>.");
11649
11663
  }),
11650
11664
  StaticBlockCannotHaveModifier: _("Static class blocks cannot have any modifier."),
@@ -11658,10 +11672,10 @@ var TSErrors = ParseErrorEnum(_templateObject4 || (_templateObject4 = _taggedTem
11658
11672
  UnexpectedTypeCastInParameter: _("Unexpected type cast in parameter position."),
11659
11673
  UnsupportedImportTypeArgument: _("Argument in a type import must be a string literal."),
11660
11674
  UnsupportedParameterPropertyKind: _("A parameter property may not be declared using a binding pattern."),
11661
- UnsupportedSignatureParameterKind: _(_ref84 => {
11675
+ UnsupportedSignatureParameterKind: _(_ref86 => {
11662
11676
  var {
11663
11677
  type
11664
- } = _ref84;
11678
+ } = _ref86;
11665
11679
  return "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ".concat(type, ".");
11666
11680
  })
11667
11681
  }));
@@ -11707,6 +11721,10 @@ function tsIsAccessModifier(modifier) {
11707
11721
  return modifier === "private" || modifier === "public" || modifier === "protected";
11708
11722
  }
11709
11723
 
11724
+ function tsIsVarianceAnnotations(modifier) {
11725
+ return modifier === "in" || modifier === "out";
11726
+ }
11727
+
11710
11728
  var typescript = superClass => class extends superClass {
11711
11729
  getScopeHandler() {
11712
11730
  return TypeScriptScopeHandler;
@@ -11726,7 +11744,7 @@ var typescript = superClass => class extends superClass {
11726
11744
  }
11727
11745
 
11728
11746
  tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) {
11729
- if (!tokenIsIdentifier(this.state.type)) {
11747
+ if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58) {
11730
11748
  return undefined;
11731
11749
  }
11732
11750
 
@@ -11745,13 +11763,14 @@ var typescript = superClass => class extends superClass {
11745
11763
  return undefined;
11746
11764
  }
11747
11765
 
11748
- tsParseModifiers(_ref85) {
11766
+ tsParseModifiers(_ref87) {
11749
11767
  var {
11750
11768
  modified,
11751
11769
  allowedModifiers,
11752
11770
  disallowedModifiers,
11753
- stopOnStartOfClassStaticBlock
11754
- } = _ref85;
11771
+ stopOnStartOfClassStaticBlock,
11772
+ errorTemplate = TSErrors.InvalidModifierOnTypeMember
11773
+ } = _ref87;
11755
11774
 
11756
11775
  var enforceOrder = (loc, modifier, before, after) => {
11757
11776
  if (modifier === before && modified[after]) {
@@ -11790,6 +11809,16 @@ var typescript = superClass => class extends superClass {
11790
11809
  enforceOrder(startLoc, modifier, modifier, "readonly");
11791
11810
  modified.accessibility = modifier;
11792
11811
  }
11812
+ } else if (tsIsVarianceAnnotations(modifier)) {
11813
+ if (modified[modifier]) {
11814
+ this.raise(TSErrors.DuplicateModifier, {
11815
+ at: startLoc,
11816
+ modifier
11817
+ });
11818
+ }
11819
+
11820
+ modified[modifier] = true;
11821
+ enforceOrder(startLoc, modifier, "in", "out");
11793
11822
  } else {
11794
11823
  if (Object.hasOwnProperty.call(modified, modifier)) {
11795
11824
  this.raise(TSErrors.DuplicateModifier, {
@@ -11809,7 +11838,7 @@ var typescript = superClass => class extends superClass {
11809
11838
  }
11810
11839
 
11811
11840
  if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
11812
- this.raise(TSErrors.InvalidModifierOnTypeMember, {
11841
+ this.raise(errorTemplate, {
11813
11842
  at: startLoc,
11814
11843
  modifier
11815
11844
  });
@@ -11986,24 +12015,48 @@ var typescript = superClass => class extends superClass {
11986
12015
  node.exprName = this.tsParseEntityName();
11987
12016
  }
11988
12017
 
12018
+ if (!this.hasPrecedingLineBreak() && this.match(47)) {
12019
+ node.typeParameters = this.tsParseTypeArguments();
12020
+ }
12021
+
11989
12022
  return this.finishNode(node, "TSTypeQuery");
11990
12023
  }
11991
12024
 
12025
+ tsParseInOutModifiers(node) {
12026
+ this.tsParseModifiers({
12027
+ modified: node,
12028
+ allowedModifiers: ["in", "out"],
12029
+ disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
12030
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameter
12031
+ });
12032
+ }
12033
+
12034
+ tsParseNoneModifiers(node) {
12035
+ this.tsParseModifiers({
12036
+ modified: node,
12037
+ allowedModifiers: [],
12038
+ disallowedModifiers: ["in", "out"],
12039
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
12040
+ });
12041
+ }
12042
+
11992
12043
  tsParseTypeParameter() {
12044
+ var parseModifiers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.tsParseNoneModifiers.bind(this);
11993
12045
  var node = this.startNode();
12046
+ parseModifiers(node);
11994
12047
  node.name = this.tsParseTypeParameterName();
11995
12048
  node.constraint = this.tsEatThenParseType(81);
11996
12049
  node.default = this.tsEatThenParseType(29);
11997
12050
  return this.finishNode(node, "TSTypeParameter");
11998
12051
  }
11999
12052
 
12000
- tsTryParseTypeParameters() {
12053
+ tsTryParseTypeParameters(parseModifiers) {
12001
12054
  if (this.match(47)) {
12002
- return this.tsParseTypeParameters();
12055
+ return this.tsParseTypeParameters(parseModifiers);
12003
12056
  }
12004
12057
  }
12005
12058
 
12006
- tsParseTypeParameters() {
12059
+ tsParseTypeParameters(parseModifiers) {
12007
12060
  var node = this.startNode();
12008
12061
 
12009
12062
  if (this.match(47) || this.match(138)) {
@@ -12015,7 +12068,7 @@ var typescript = superClass => class extends superClass {
12015
12068
  var refTrailingCommaPos = {
12016
12069
  value: -1
12017
12070
  };
12018
- node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
12071
+ node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos);
12019
12072
 
12020
12073
  if (node.params.length === 0) {
12021
12074
  this.raise(TSErrors.EmptyTypeParameters, {
@@ -12406,7 +12459,7 @@ var typescript = superClass => class extends superClass {
12406
12459
  this.next();
12407
12460
  }
12408
12461
 
12409
- this.tsFillSignature(19, node);
12462
+ this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node));
12410
12463
  return this.finishNode(node, type);
12411
12464
  }
12412
12465
 
@@ -12575,13 +12628,24 @@ var typescript = superClass => class extends superClass {
12575
12628
  this.expectContextual(112);
12576
12629
  var typeParameter = this.startNode();
12577
12630
  typeParameter.name = this.tsParseTypeParameterName();
12631
+ typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
12578
12632
  node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
12579
12633
  return this.finishNode(node, "TSInferType");
12580
12634
  }
12581
12635
 
12636
+ tsParseConstraintForInferType() {
12637
+ if (this.eat(81)) {
12638
+ var constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType());
12639
+
12640
+ if (this.state.inDisallowConditionalTypesContext || !this.match(17)) {
12641
+ return constraint;
12642
+ }
12643
+ }
12644
+ }
12645
+
12582
12646
  tsParseTypeOperatorOrHigher() {
12583
12647
  var isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
12584
- return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
12648
+ return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(112) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
12585
12649
  }
12586
12650
 
12587
12651
  tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
@@ -12783,17 +12847,17 @@ var typescript = superClass => class extends superClass {
12783
12847
  assert(this.state.inType);
12784
12848
  var type = this.tsParseNonConditionalType();
12785
12849
 
12786
- if (this.hasPrecedingLineBreak() || !this.eat(81)) {
12850
+ if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) {
12787
12851
  return type;
12788
12852
  }
12789
12853
 
12790
12854
  var node = this.startNodeAtNode(type);
12791
12855
  node.checkType = type;
12792
- node.extendsType = this.tsParseNonConditionalType();
12856
+ node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType());
12793
12857
  this.expect(17);
12794
- node.trueType = this.tsParseType();
12858
+ node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
12795
12859
  this.expect(14);
12796
- node.falseType = this.tsParseType();
12860
+ node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType());
12797
12861
  return this.finishNode(node, "TSConditionalType");
12798
12862
  }
12799
12863
 
@@ -12834,7 +12898,16 @@ var typescript = superClass => class extends superClass {
12834
12898
 
12835
12899
  tsParseHeritageClause(token) {
12836
12900
  var originalStartLoc = this.state.startLoc;
12837
- var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
12901
+ var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
12902
+ var node = this.startNode();
12903
+ node.expression = this.tsParseEntityName();
12904
+
12905
+ if (this.match(47)) {
12906
+ node.typeParameters = this.tsParseTypeArguments();
12907
+ }
12908
+
12909
+ return this.finishNode(node, "TSExpressionWithTypeArguments");
12910
+ });
12838
12911
 
12839
12912
  if (!delimitedList.length) {
12840
12913
  this.raise(TSErrors.EmptyHeritageClauseType, {
@@ -12846,17 +12919,6 @@ var typescript = superClass => class extends superClass {
12846
12919
  return delimitedList;
12847
12920
  }
12848
12921
 
12849
- tsParseExpressionWithTypeArguments() {
12850
- var node = this.startNode();
12851
- node.expression = this.tsParseEntityName();
12852
-
12853
- if (this.match(47)) {
12854
- node.typeParameters = this.tsParseTypeArguments();
12855
- }
12856
-
12857
- return this.finishNode(node, "TSExpressionWithTypeArguments");
12858
- }
12859
-
12860
12922
  tsParseInterfaceDeclaration(node) {
12861
12923
  var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12862
12924
  if (this.hasFollowingLineBreak()) return null;
@@ -12873,7 +12935,7 @@ var typescript = superClass => class extends superClass {
12873
12935
  });
12874
12936
  }
12875
12937
 
12876
- node.typeParameters = this.tsTryParseTypeParameters();
12938
+ node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
12877
12939
 
12878
12940
  if (this.eat(81)) {
12879
12941
  node.extends = this.tsParseHeritageClause("extends");
@@ -12889,7 +12951,7 @@ var typescript = superClass => class extends superClass {
12889
12951
  node.id = this.parseIdentifier();
12890
12952
  this.checkIdentifier(node.id, BIND_TS_TYPE);
12891
12953
  node.typeAnnotation = this.tsInType(() => {
12892
- node.typeParameters = this.tsTryParseTypeParameters();
12954
+ node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
12893
12955
  this.expect(29);
12894
12956
 
12895
12957
  if (this.isContextual(111) && this.lookahead().type !== 16) {
@@ -12927,6 +12989,28 @@ var typescript = superClass => class extends superClass {
12927
12989
  }
12928
12990
  }
12929
12991
 
12992
+ tsInDisallowConditionalTypesContext(cb) {
12993
+ var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
12994
+ this.state.inDisallowConditionalTypesContext = true;
12995
+
12996
+ try {
12997
+ return cb();
12998
+ } finally {
12999
+ this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
13000
+ }
13001
+ }
13002
+
13003
+ tsInAllowConditionalTypesContext(cb) {
13004
+ var oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext;
13005
+ this.state.inDisallowConditionalTypesContext = false;
13006
+
13007
+ try {
13008
+ return cb();
13009
+ } finally {
13010
+ this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext;
13011
+ }
13012
+ }
13013
+
12930
13014
  tsEatThenParseType(token) {
12931
13015
  return !this.match(token) ? undefined : this.tsNextThenParseType();
12932
13016
  }
@@ -13446,61 +13530,78 @@ var typescript = superClass => class extends superClass {
13446
13530
  }
13447
13531
  }
13448
13532
 
13449
- var node = this.startNodeAt(startPos, startLoc);
13450
- node.callee = base;
13451
13533
  var typeArguments = this.tsParseTypeArgumentsInExpression();
13534
+ if (!typeArguments) return;
13452
13535
 
13453
- if (typeArguments) {
13454
- if (isOptionalCall && !this.match(10)) {
13455
- missingParenErrorLoc = this.state.curPosition();
13456
- this.unexpected();
13457
- }
13536
+ if (isOptionalCall && !this.match(10)) {
13537
+ missingParenErrorLoc = this.state.curPosition();
13538
+ return;
13539
+ }
13458
13540
 
13459
- if (!noCalls && this.eat(10)) {
13460
- node.arguments = this.parseCallExpressionArguments(11, false);
13461
- this.tsCheckForInvalidTypeCasts(node.arguments);
13462
- node.typeParameters = typeArguments;
13541
+ if (tokenIsTemplate(this.state.type)) {
13542
+ var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
13463
13543
 
13464
- if (state.optionalChainMember) {
13465
- node.optional = isOptionalCall;
13466
- }
13544
+ _result.typeParameters = typeArguments;
13545
+ return _result;
13546
+ }
13547
+
13548
+ if (!noCalls && this.eat(10)) {
13549
+ var _node9 = this.startNodeAt(startPos, startLoc);
13467
13550
 
13468
- return this.finishCallExpression(node, state.optionalChainMember);
13469
- } else if (tokenIsTemplate(this.state.type)) {
13470
- var _result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
13551
+ _node9.callee = base;
13552
+ _node9.arguments = this.parseCallExpressionArguments(11, false);
13553
+ this.tsCheckForInvalidTypeCasts(_node9.arguments);
13554
+ _node9.typeParameters = typeArguments;
13471
13555
 
13472
- _result.typeParameters = typeArguments;
13473
- return _result;
13556
+ if (state.optionalChainMember) {
13557
+ _node9.optional = isOptionalCall;
13474
13558
  }
13559
+
13560
+ return this.finishCallExpression(_node9, state.optionalChainMember);
13475
13561
  }
13476
13562
 
13477
- this.unexpected();
13563
+ var tokenType = this.state.type;
13564
+
13565
+ if (tokenType === 48 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
13566
+ return;
13567
+ }
13568
+
13569
+ var node = this.startNodeAt(startPos, startLoc);
13570
+ node.expression = base;
13571
+ node.typeParameters = typeArguments;
13572
+ return this.finishNode(node, "TSInstantiationExpression");
13478
13573
  });
13479
13574
 
13480
13575
  if (missingParenErrorLoc) {
13481
13576
  this.unexpected(missingParenErrorLoc, 10);
13482
13577
  }
13483
13578
 
13484
- if (result) return result;
13579
+ if (result) {
13580
+ if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) {
13581
+ this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, {
13582
+ at: this.state.startLoc
13583
+ });
13584
+ }
13585
+
13586
+ return result;
13587
+ }
13485
13588
  }
13486
13589
 
13487
13590
  return super.parseSubscript(base, startPos, startLoc, noCalls, state);
13488
13591
  }
13489
13592
 
13490
- parseNewArguments(node) {
13491
- if (this.match(47) || this.match(51)) {
13492
- var typeParameters = this.tsTryParseAndCatch(() => {
13493
- var args = this.tsParseTypeArgumentsInExpression();
13494
- if (!this.match(10)) this.unexpected();
13495
- return args;
13496
- });
13593
+ parseNewCallee(node) {
13594
+ var _callee$extra;
13497
13595
 
13498
- if (typeParameters) {
13499
- node.typeParameters = typeParameters;
13500
- }
13501
- }
13596
+ super.parseNewCallee(node);
13597
+ var {
13598
+ callee
13599
+ } = node;
13502
13600
 
13503
- super.parseNewArguments(node);
13601
+ if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) {
13602
+ node.typeParameters = callee.typeParameters;
13603
+ node.callee = callee.expression;
13604
+ }
13504
13605
  }
13505
13606
 
13506
13607
  parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
@@ -13688,7 +13789,9 @@ var typescript = superClass => class extends superClass {
13688
13789
  this.tsParseModifiers({
13689
13790
  modified: member,
13690
13791
  allowedModifiers: modifiers,
13691
- stopOnStartOfClassStaticBlock: true
13792
+ disallowedModifiers: ["in", "out"],
13793
+ stopOnStartOfClassStaticBlock: true,
13794
+ errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions
13692
13795
  });
13693
13796
 
13694
13797
  var callParseClassMemberWithIsStatic = () => {
@@ -13867,7 +13970,7 @@ var typescript = superClass => class extends superClass {
13867
13970
  }
13868
13971
 
13869
13972
  super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS);
13870
- var typeParameters = this.tsTryParseTypeParameters();
13973
+ var typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this));
13871
13974
  if (typeParameters) node.typeParameters = typeParameters;
13872
13975
  }
13873
13976
 
@@ -13973,8 +14076,8 @@ var typescript = superClass => class extends superClass {
13973
14076
  var typeParameters = this.tsTryParseTypeParameters();
13974
14077
  if (typeParameters) prop.typeParameters = typeParameters;
13975
14078
 
13976
- for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
13977
- args[_key5 - 1] = arguments[_key5];
14079
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
14080
+ args[_key4 - 1] = arguments[_key4];
13978
14081
  }
13979
14082
 
13980
14083
  super.parseObjPropValue(prop, ...args);
@@ -14010,8 +14113,8 @@ var typescript = superClass => class extends superClass {
14010
14113
  }
14011
14114
 
14012
14115
  parseMaybeAssign() {
14013
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
14014
- args[_key6] = arguments[_key6];
14116
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
14117
+ args[_key5] = arguments[_key5];
14015
14118
  }
14016
14119
 
14017
14120
  var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2, _jsx4, _typeCast3;
@@ -14038,10 +14141,10 @@ var typescript = superClass => class extends superClass {
14038
14141
  return super.parseMaybeAssign(...args);
14039
14142
  }
14040
14143
 
14144
+ if (!state || state === this.state) state = this.state.clone();
14041
14145
  var typeParameters;
14042
- state = state || this.state.clone();
14043
14146
  var arrow = this.tryParse(abort => {
14044
- var _expr$extra, _typeParameters, _expr$typeParameters$;
14147
+ var _expr$extra, _typeParameters;
14045
14148
 
14046
14149
  typeParameters = this.tsParseTypeParameters();
14047
14150
  var expr = super.parseMaybeAssign(...args);
@@ -14055,12 +14158,6 @@ var typescript = superClass => class extends superClass {
14055
14158
  }
14056
14159
 
14057
14160
  expr.typeParameters = typeParameters;
14058
-
14059
- if (this.hasPlugin("jsx") && expr.typeParameters.params.length === 1 && !((_expr$typeParameters$ = expr.typeParameters.extra) != null && _expr$typeParameters$.trailingComma)) {
14060
- var parameter = expr.typeParameters.params[0];
14061
- if (!parameter.constraint) ;
14062
- }
14063
-
14064
14161
  return expr;
14065
14162
  }, state);
14066
14163
 
@@ -14167,23 +14264,33 @@ var typescript = superClass => class extends superClass {
14167
14264
  var isLHS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
14168
14265
 
14169
14266
  switch (node.type) {
14170
- case "TSTypeCastExpression":
14171
- return super.toAssignable(this.typeCastToParameter(node), isLHS);
14172
-
14173
- case "TSParameterProperty":
14174
- return super.toAssignable(node, isLHS);
14175
-
14176
14267
  case "ParenthesizedExpression":
14177
- return this.toAssignableParenthesizedExpression(node, isLHS);
14268
+ this.toAssignableParenthesizedExpression(node, isLHS);
14269
+ break;
14178
14270
 
14179
14271
  case "TSAsExpression":
14180
14272
  case "TSNonNullExpression":
14181
14273
  case "TSTypeAssertion":
14182
- node.expression = this.toAssignable(node.expression, isLHS);
14183
- return node;
14274
+ if (isLHS) {
14275
+ this.expressionScope.recordArrowParemeterBindingError(TSErrors.UnexpectedTypeCastInParameter, {
14276
+ at: node
14277
+ });
14278
+ } else {
14279
+ this.raise(TSErrors.UnexpectedTypeCastInParameter, {
14280
+ at: node
14281
+ });
14282
+ }
14283
+
14284
+ this.toAssignable(node.expression, isLHS);
14285
+ break;
14286
+
14287
+ case "AssignmentExpression":
14288
+ if (!isLHS && node.left.type === "TSTypeCastExpression") {
14289
+ node.left = this.typeCastToParameter(node.left);
14290
+ }
14184
14291
 
14185
14292
  default:
14186
- return super.toAssignable(node, isLHS);
14293
+ super.toAssignable(node, isLHS);
14187
14294
  }
14188
14295
  }
14189
14296
 
@@ -14193,22 +14300,35 @@ var typescript = superClass => class extends superClass {
14193
14300
  case "TSNonNullExpression":
14194
14301
  case "TSTypeAssertion":
14195
14302
  case "ParenthesizedExpression":
14196
- node.expression = this.toAssignable(node.expression, isLHS);
14197
- return node;
14303
+ this.toAssignable(node.expression, isLHS);
14304
+ break;
14198
14305
 
14199
14306
  default:
14200
- return super.toAssignable(node, isLHS);
14307
+ super.toAssignable(node, isLHS);
14201
14308
  }
14202
14309
  }
14203
14310
 
14204
- isValidLVal(type, isParenthesized, binding) {
14311
+ checkToRestConversion(node, allowPattern) {
14312
+ switch (node.type) {
14313
+ case "TSAsExpression":
14314
+ case "TSTypeAssertion":
14315
+ case "TSNonNullExpression":
14316
+ this.checkToRestConversion(node.expression, false);
14317
+ break;
14318
+
14319
+ default:
14320
+ super.checkToRestConversion(node, allowPattern);
14321
+ }
14322
+ }
14323
+
14324
+ isValidLVal(type, isUnparenthesizedInAssign, binding) {
14205
14325
  return getOwn$1({
14206
14326
  TSTypeCastExpression: true,
14207
14327
  TSParameterProperty: "parameter",
14208
14328
  TSNonNullExpression: "expression",
14209
- TSAsExpression: (binding !== BIND_NONE || isParenthesized) && ["expression", true],
14210
- TSTypeAssertion: (binding !== BIND_NONE || isParenthesized) && ["expression", true]
14211
- }, type) || super.isValidLVal(type, isParenthesized, binding);
14329
+ TSAsExpression: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true],
14330
+ TSTypeAssertion: (binding !== BIND_NONE || !isUnparenthesizedInAssign) && ["expression", true]
14331
+ }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding);
14212
14332
  }
14213
14333
 
14214
14334
  parseBindingAtom() {
@@ -14311,28 +14431,13 @@ var typescript = superClass => class extends superClass {
14311
14431
  toAssignableList(exprList) {
14312
14432
  for (var i = 0; i < exprList.length; i++) {
14313
14433
  var expr = exprList[i];
14314
- if (!expr) continue;
14315
-
14316
- switch (expr.type) {
14317
- case "TSTypeCastExpression":
14318
- exprList[i] = this.typeCastToParameter(expr);
14319
- break;
14320
14434
 
14321
- case "TSAsExpression":
14322
- case "TSTypeAssertion":
14323
- if (!this.state.maybeInArrowParameters) {
14324
- exprList[i] = this.typeCastToParameter(expr);
14325
- } else {
14326
- this.raise(TSErrors.UnexpectedTypeCastInParameter, {
14327
- at: expr
14328
- });
14329
- }
14330
-
14331
- break;
14435
+ if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") {
14436
+ exprList[i] = this.typeCastToParameter(expr);
14332
14437
  }
14333
14438
  }
14334
14439
 
14335
- return super.toAssignableList(...arguments);
14440
+ super.toAssignableList(...arguments);
14336
14441
  }
14337
14442
 
14338
14443
  typeCastToParameter(node) {
@@ -14402,8 +14507,8 @@ var typescript = superClass => class extends superClass {
14402
14507
  this.state.inAbstractClass = !!node.abstract;
14403
14508
 
14404
14509
  try {
14405
- for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
14406
- args[_key7 - 1] = arguments[_key7];
14510
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
14511
+ args[_key6 - 1] = arguments[_key6];
14407
14512
  }
14408
14513
 
14409
14514
  return super.parseClass(node, ...args);
@@ -14527,7 +14632,16 @@ var typescript = superClass => class extends superClass {
14527
14632
  }
14528
14633
  } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14529
14634
  hasTypeSpecifier = true;
14530
- leftOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
14635
+
14636
+ if (isImport) {
14637
+ leftOfAs = this.parseIdentifier(true);
14638
+
14639
+ if (!this.isContextual(93)) {
14640
+ this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
14641
+ }
14642
+ } else {
14643
+ leftOfAs = this.parseModuleExportName();
14644
+ }
14531
14645
  }
14532
14646
 
14533
14647
  if (hasTypeSpecifier && isInTypeOnlyImportExport) {
@@ -14626,8 +14740,8 @@ var placeholders = superClass => class extends superClass {
14626
14740
  }
14627
14741
 
14628
14742
  isValidLVal(type) {
14629
- for (var _len8 = arguments.length, rest = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
14630
- rest[_key8 - 1] = arguments[_key8];
14743
+ for (var _len7 = arguments.length, rest = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
14744
+ rest[_key7 - 1] = arguments[_key7];
14631
14745
  }
14632
14746
 
14633
14747
  return type === "Placeholder" || super.isValidLVal(type, ...rest);
@@ -14636,10 +14750,9 @@ var placeholders = superClass => class extends superClass {
14636
14750
  toAssignable(node) {
14637
14751
  if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
14638
14752
  node.expectedNode = "Pattern";
14639
- return node;
14753
+ } else {
14754
+ super.toAssignable(...arguments);
14640
14755
  }
14641
-
14642
- return super.toAssignable(...arguments);
14643
14756
  }
14644
14757
 
14645
14758
  isLet(context) {
@@ -14951,9 +15064,9 @@ function validatePlugins(plugins) {
14951
15064
  throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
14952
15065
  }
14953
15066
 
14954
- var moduleAttributesVerionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
15067
+ var moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
14955
15068
 
14956
- if (moduleAttributesVerionPluginOption !== "may-2020") {
15069
+ if (moduleAttributesVersionPluginOption !== "may-2020") {
14957
15070
  throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
14958
15071
  }
14959
15072
  }
@@ -15027,7 +15140,7 @@ class LValParser extends NodeUtils {
15027
15140
 
15028
15141
  if (isLHS) {
15029
15142
  if (parenthesized.type === "Identifier") {
15030
- this.expressionScope.recordParenthesizedIdentifierError({
15143
+ this.expressionScope.recordArrowParemeterBindingError(Errors.InvalidParenthesizedAssignment, {
15031
15144
  at: node
15032
15145
  });
15033
15146
  } else if (parenthesized.type !== "MemberExpression") {
@@ -15086,11 +15199,7 @@ class LValParser extends NodeUtils {
15086
15199
 
15087
15200
  case "SpreadElement":
15088
15201
  {
15089
- this.checkToRestConversion(node);
15090
- node.type = "RestElement";
15091
- var arg = node.argument;
15092
- this.toAssignable(arg, isLHS);
15093
- break;
15202
+ throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller.");
15094
15203
  }
15095
15204
 
15096
15205
  case "ArrayExpression":
@@ -15114,8 +15223,6 @@ class LValParser extends NodeUtils {
15114
15223
  this.toAssignable(parenthesized, isLHS);
15115
15224
  break;
15116
15225
  }
15117
-
15118
- return node;
15119
15226
  }
15120
15227
 
15121
15228
  toAssignableObjectExpressionProp(prop, isLast, isLHS) {
@@ -15123,58 +15230,50 @@ class LValParser extends NodeUtils {
15123
15230
  this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, {
15124
15231
  at: prop.key
15125
15232
  });
15126
- } else if (prop.type === "SpreadElement" && !isLast) {
15127
- this.raise(Errors.RestTrailingComma, {
15128
- at: prop
15129
- });
15233
+ } else if (prop.type === "SpreadElement") {
15234
+ prop.type = "RestElement";
15235
+ var arg = prop.argument;
15236
+ this.checkToRestConversion(arg, false);
15237
+ this.toAssignable(arg, isLHS);
15238
+
15239
+ if (!isLast) {
15240
+ this.raise(Errors.RestTrailingComma, {
15241
+ at: prop
15242
+ });
15243
+ }
15130
15244
  } else {
15131
15245
  this.toAssignable(prop, isLHS);
15132
15246
  }
15133
15247
  }
15134
15248
 
15135
15249
  toAssignableList(exprList, trailingCommaLoc, isLHS) {
15136
- var end = exprList.length;
15137
-
15138
- if (end) {
15139
- var last = exprList[end - 1];
15250
+ var end = exprList.length - 1;
15140
15251
 
15141
- if ((last == null ? void 0 : last.type) === "RestElement") {
15142
- --end;
15143
- } else if ((last == null ? void 0 : last.type) === "SpreadElement") {
15144
- last.type = "RestElement";
15145
- var arg = last.argument;
15146
- this.toAssignable(arg, isLHS);
15147
- arg = unwrapParenthesizedExpression(arg);
15148
-
15149
- if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
15150
- this.unexpected(arg.start);
15151
- }
15152
-
15153
- if (trailingCommaLoc) {
15154
- this.raise(Errors.RestTrailingComma, {
15155
- at: trailingCommaLoc
15156
- });
15157
- }
15158
-
15159
- --end;
15160
- }
15161
- }
15162
-
15163
- for (var i = 0; i < end; i++) {
15252
+ for (var i = 0; i <= end; i++) {
15164
15253
  var elt = exprList[i];
15254
+ if (!elt) continue;
15165
15255
 
15166
- if (elt) {
15256
+ if (elt.type === "SpreadElement") {
15257
+ elt.type = "RestElement";
15258
+ var arg = elt.argument;
15259
+ this.checkToRestConversion(arg, true);
15260
+ this.toAssignable(arg, isLHS);
15261
+ } else {
15167
15262
  this.toAssignable(elt, isLHS);
15263
+ }
15168
15264
 
15169
- if (elt.type === "RestElement") {
15265
+ if (elt.type === "RestElement") {
15266
+ if (i < end) {
15170
15267
  this.raise(Errors.RestTrailingComma, {
15171
15268
  at: elt
15172
15269
  });
15270
+ } else if (trailingCommaLoc) {
15271
+ this.raise(Errors.RestTrailingComma, {
15272
+ at: trailingCommaLoc
15273
+ });
15173
15274
  }
15174
15275
  }
15175
15276
  }
15176
-
15177
- return exprList;
15178
15277
  }
15179
15278
 
15180
15279
  isAssignable(node, isBinding) {
@@ -15364,7 +15463,7 @@ class LValParser extends NodeUtils {
15364
15463
  return this.finishNode(node, "AssignmentPattern");
15365
15464
  }
15366
15465
 
15367
- isValidLVal(type, isParenthesized, binding) {
15466
+ isValidLVal(type, isUnparenthesizedInAssign, binding) {
15368
15467
  return getOwn({
15369
15468
  AssignmentPattern: "left",
15370
15469
  RestElement: "argument",
@@ -15375,7 +15474,7 @@ class LValParser extends NodeUtils {
15375
15474
  }, type);
15376
15475
  }
15377
15476
 
15378
- checkLVal(expression, _ref86) {
15477
+ checkLVal(expression, _ref88) {
15379
15478
  var {
15380
15479
  in: ancestor,
15381
15480
  binding = BIND_NONE,
@@ -15383,7 +15482,7 @@ class LValParser extends NodeUtils {
15383
15482
  strictModeChanged = false,
15384
15483
  allowingSloppyLetBinding = !(binding & BIND_SCOPE_LEXICAL),
15385
15484
  hasParenthesizedAncestor = false
15386
- } = _ref86;
15485
+ } = _ref88;
15387
15486
 
15388
15487
  var _expression$extra;
15389
15488
 
@@ -15419,7 +15518,7 @@ class LValParser extends NodeUtils {
15419
15518
  return;
15420
15519
  }
15421
15520
 
15422
- var validity = this.isValidLVal(expression.type, hasParenthesizedAncestor || ((_expression$extra = expression.extra) == null ? void 0 : _expression$extra.parenthesized), binding);
15521
+ var validity = this.isValidLVal(expression.type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding);
15423
15522
  if (validity === true) return;
15424
15523
 
15425
15524
  if (validity === false) {
@@ -15486,11 +15585,24 @@ class LValParser extends NodeUtils {
15486
15585
  this.scope.declareName(identifier.name, binding, identifier.loc.start);
15487
15586
  }
15488
15587
 
15489
- checkToRestConversion(node) {
15490
- if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
15491
- this.raise(Errors.InvalidRestAssignmentPattern, {
15492
- at: node.argument
15493
- });
15588
+ checkToRestConversion(node, allowPattern) {
15589
+ switch (node.type) {
15590
+ case "ParenthesizedExpression":
15591
+ this.checkToRestConversion(node.expression, allowPattern);
15592
+ break;
15593
+
15594
+ case "Identifier":
15595
+ case "MemberExpression":
15596
+ break;
15597
+
15598
+ case "ArrayExpression":
15599
+ case "ObjectExpression":
15600
+ if (allowPattern) break;
15601
+
15602
+ default:
15603
+ this.raise(Errors.InvalidRestAssignmentPattern, {
15604
+ at: node
15605
+ });
15494
15606
  }
15495
15607
  }
15496
15608
 
@@ -15651,7 +15763,8 @@ class ExpressionParser extends LValParser {
15651
15763
  node.operator = operator;
15652
15764
 
15653
15765
  if (this.match(29)) {
15654
- node.left = this.toAssignable(left, true);
15766
+ this.toAssignable(left, true);
15767
+ node.left = left;
15655
15768
 
15656
15769
  if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startPos) {
15657
15770
  refExpressionErrors.doubleProtoLoc = null;
@@ -15951,14 +16064,14 @@ class ExpressionParser extends LValParser {
15951
16064
  if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
15952
16065
 
15953
16066
  while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
15954
- var _node9 = this.startNodeAt(startPos, startLoc);
16067
+ var _node10 = this.startNodeAt(startPos, startLoc);
15955
16068
 
15956
- _node9.operator = this.state.value;
15957
- _node9.prefix = false;
15958
- _node9.argument = expr;
16069
+ _node10.operator = this.state.value;
16070
+ _node10.prefix = false;
16071
+ _node10.argument = expr;
15959
16072
  this.next();
15960
16073
  this.checkLVal(expr, {
15961
- in: expr = this.finishNode(_node9, "UpdateExpression")
16074
+ in: expr = this.finishNode(_node10, "UpdateExpression")
15962
16075
  });
15963
16076
  }
15964
16077
 
@@ -16818,6 +16931,20 @@ class ExpressionParser extends LValParser {
16818
16931
  }
16819
16932
 
16820
16933
  parseNew(node) {
16934
+ this.parseNewCallee(node);
16935
+
16936
+ if (this.eat(10)) {
16937
+ var args = this.parseExprList(11);
16938
+ this.toReferencedList(args);
16939
+ node.arguments = args;
16940
+ } else {
16941
+ node.arguments = [];
16942
+ }
16943
+
16944
+ return this.finishNode(node, "NewExpression");
16945
+ }
16946
+
16947
+ parseNewCallee(node) {
16821
16948
  node.callee = this.parseNoCallExpr();
16822
16949
 
16823
16950
  if (node.callee.type === "Import") {
@@ -16833,19 +16960,6 @@ class ExpressionParser extends LValParser {
16833
16960
  at: this.state.startLoc
16834
16961
  });
16835
16962
  }
16836
-
16837
- this.parseNewArguments(node);
16838
- return this.finishNode(node, "NewExpression");
16839
- }
16840
-
16841
- parseNewArguments(node) {
16842
- if (this.eat(10)) {
16843
- var args = this.parseExprList(11);
16844
- this.toReferencedList(args);
16845
- node.arguments = args;
16846
- } else {
16847
- node.arguments = [];
16848
- }
16849
16963
  }
16850
16964
 
16851
16965
  parseTemplateElement(isTagged) {
@@ -17252,7 +17366,8 @@ class ExpressionParser extends LValParser {
17252
17366
  }
17253
17367
 
17254
17368
  setArrowFunctionParameters(node, params, trailingCommaLoc) {
17255
- node.params = this.toAssignableList(params, trailingCommaLoc, false);
17369
+ this.toAssignableList(params, trailingCommaLoc, false);
17370
+ node.params = params;
17256
17371
  }
17257
17372
 
17258
17373
  parseFunctionBodyAndFinish(node, type) {
@@ -18172,7 +18287,7 @@ class StatementParser extends ExpressionParser {
18172
18287
  }
18173
18288
 
18174
18289
  parseDecorator() {
18175
- this.expectOnePlugin(["decorators-legacy", "decorators"]);
18290
+ this.expectOnePlugin(["decorators", "decorators-legacy"]);
18176
18291
  var node = this.startNode();
18177
18292
  this.next();
18178
18293
 
@@ -18193,12 +18308,12 @@ class StatementParser extends ExpressionParser {
18193
18308
  expr = this.parseIdentifier(false);
18194
18309
 
18195
18310
  while (this.eat(16)) {
18196
- var _node10 = this.startNodeAt(startPos, startLoc);
18311
+ var _node11 = this.startNodeAt(startPos, startLoc);
18197
18312
 
18198
- _node10.object = expr;
18199
- _node10.property = this.parseIdentifier(true);
18200
- _node10.computed = false;
18201
- expr = this.finishNode(_node10, "MemberExpression");
18313
+ _node11.object = expr;
18314
+ _node11.property = this.parseIdentifier(true);
18315
+ _node11.computed = false;
18316
+ expr = this.finishNode(_node11, "MemberExpression");
18202
18317
  }
18203
18318
  }
18204
18319
 
@@ -19419,6 +19534,7 @@ class StatementParser extends ExpressionParser {
19419
19534
 
19420
19535
  if (assertions) {
19421
19536
  node.assertions = assertions;
19537
+ this.checkJSONModuleImport(node);
19422
19538
  }
19423
19539
  } else if (expect) {
19424
19540
  this.unexpected();
@@ -19604,6 +19720,50 @@ class StatementParser extends ExpressionParser {
19604
19720
  return this.parseIdentifier(true);
19605
19721
  }
19606
19722
 
19723
+ isJSONModuleImport(node) {
19724
+ if (node.assertions != null) {
19725
+ return node.assertions.some(_ref89 => {
19726
+ var {
19727
+ key,
19728
+ value
19729
+ } = _ref89;
19730
+ return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type");
19731
+ });
19732
+ }
19733
+
19734
+ return false;
19735
+ }
19736
+
19737
+ checkJSONModuleImport(node) {
19738
+ if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") {
19739
+ var {
19740
+ specifiers
19741
+ } = node;
19742
+
19743
+ if (node.specifiers != null) {
19744
+ var nonDefaultNamedSpecifier = specifiers.find(specifier => {
19745
+ var imported;
19746
+
19747
+ if (specifier.type === "ExportSpecifier") {
19748
+ imported = specifier.local;
19749
+ } else if (specifier.type === "ImportSpecifier") {
19750
+ imported = specifier.imported;
19751
+ }
19752
+
19753
+ if (imported !== undefined) {
19754
+ return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default";
19755
+ }
19756
+ });
19757
+
19758
+ if (nonDefaultNamedSpecifier !== undefined) {
19759
+ this.raise(Errors.ImportJSONBindingNotDefault, {
19760
+ at: nonDefaultNamedSpecifier.loc.start
19761
+ });
19762
+ }
19763
+ }
19764
+ }
19765
+ }
19766
+
19607
19767
  parseImport(node) {
19608
19768
  node.specifiers = [];
19609
19769
 
@@ -19628,6 +19788,7 @@ class StatementParser extends ExpressionParser {
19628
19788
  }
19629
19789
  }
19630
19790
 
19791
+ this.checkJSONModuleImport(node);
19631
19792
  this.semicolon();
19632
19793
  return this.finishNode(node, "ImportDeclaration");
19633
19794
  }
@@ -20636,7 +20797,7 @@ function lint(source) {
20636
20797
  loc: {
20637
20798
  start: node.loc.start,
20638
20799
  end: {
20639
- line: node.loc.end.line,
20800
+ line: node.loc.start.line,
20640
20801
  // Only decorate the "var".
20641
20802
  column: node.loc.start.column + 3
20642
20803
  }
@@ -22869,5 +23030,38 @@ function debounceByAnimationFrame(fn) {
22869
23030
  };
22870
23031
  }
22871
23032
 
22872
- export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, computeRealRoutePath, convertValueByPrecision, cook, createProviderClass, debounceByAnimationFrame, deepFreeze, formatValue, getDependencyMapOfContext, getDepsOfTemplates, getDllAndDepsByResource, getDllAndDepsOfBricks, getDllAndDepsOfStoryboard, getTemplateDepsOfStoryboard, hasOwnProperty$1 as hasOwnProperty, inject, isBrickNode, isCustomTemplateNode, isEvaluable, isObject, isRouteNode, isSnippetNode, lint, loadScript, mapCustomApisToNameAndNamespace, matchPath, normalizeBuilderNode, normalizeMenu, parseForAnalysis, precook, precookFunction, preevaluate, prefetchScript, resolveContextConcurrently, restoreDynamicTemplates, scanAppGetMenuInAny, scanAppGetMenuInStoryboard, scanBricksInBrickConf, scanBricksInStoryboard, scanCustomApisInStoryboard, scanI18NInAny, scanI18NInStoryboard, scanPermissionActionsInAny, scanPermissionActionsInStoryboard, scanProcessorsInAny, scanProcessorsInStoryboard, scanRouteAliasInStoryboard, scanStoryboard, scanTemplatesInBrick, scanTemplatesInStoryboard, shouldAllowRecursiveEvaluations, smartDisplayForEvaluableString, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackContext, trackState, transform, transformAndInject, visitStoryboardExpressions, visitStoryboardFunctions };
23033
+ var INSTALLED_APPS = "INSTALLED_APPS";
23034
+ var has = "has";
23035
+ function scanInstalledAppsInStoryboard(storyboard) {
23036
+ var _storyboard$meta;
23037
+
23038
+ var collection = new Set();
23039
+ var beforeVisitInstalledApps = beforeVisitInstalledAppsFactory(collection);
23040
+ var {
23041
+ customTemplates,
23042
+ functions
23043
+ } = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
23044
+ visitStoryboardExpressions([storyboard.routes, customTemplates], beforeVisitInstalledApps, INSTALLED_APPS);
23045
+ visitStoryboardFunctions(functions, beforeVisitInstalledApps);
23046
+ return Array.from(collection);
23047
+ }
23048
+
23049
+ function beforeVisitInstalledAppsFactory(collection) {
23050
+ return function beforeVisitPermissions(node, parent) {
23051
+ if (node.name === INSTALLED_APPS) {
23052
+ var memberParent = parent[parent.length - 1];
23053
+ var callParent = parent[parent.length - 2];
23054
+
23055
+ if ((callParent === null || callParent === void 0 ? void 0 : callParent.node.type) === "CallExpression" && (callParent === null || callParent === void 0 ? void 0 : callParent.key) === "callee" && (memberParent === null || memberParent === void 0 ? void 0 : memberParent.node.type) === "MemberExpression" && memberParent.key === "object" && !memberParent.node.computed && memberParent.node.property.type === "Identifier" && memberParent.node.property.name === has) {
23056
+ var args = callParent.node.arguments;
23057
+
23058
+ if (args.length > 0 && args[0].type === "Literal" && typeof args[0].value === "string") {
23059
+ collection.add(args[0].value);
23060
+ }
23061
+ }
23062
+ }
23063
+ };
23064
+ }
23065
+
23066
+ export { JsonStorage, PrecookFunctionVisitor, PrecookVisitor, asyncProcessBrick, asyncProcessStoryboard, computeRealRoutePath, convertValueByPrecision, cook, createProviderClass, debounceByAnimationFrame, deepFreeze, formatValue, getDependencyMapOfContext, getDepsOfTemplates, getDllAndDepsByResource, getDllAndDepsOfBricks, getDllAndDepsOfStoryboard, getTemplateDepsOfStoryboard, hasOwnProperty$1 as hasOwnProperty, inject, isBrickNode, isCustomTemplateNode, isEvaluable, isObject, isRouteNode, isSnippetNode, lint, loadScript, mapCustomApisToNameAndNamespace, matchPath, normalizeBuilderNode, normalizeMenu, parseForAnalysis, precook, precookFunction, preevaluate, prefetchScript, resolveContextConcurrently, restoreDynamicTemplates, scanAppGetMenuInAny, scanAppGetMenuInStoryboard, scanBricksInBrickConf, scanBricksInStoryboard, scanCustomApisInStoryboard, scanI18NInAny, scanI18NInStoryboard, scanInstalledAppsInStoryboard, scanPermissionActionsInAny, scanPermissionActionsInStoryboard, scanProcessorsInAny, scanProcessorsInStoryboard, scanRouteAliasInStoryboard, scanStoryboard, scanTemplatesInBrick, scanTemplatesInStoryboard, shouldAllowRecursiveEvaluations, smartDisplayForEvaluableString, syncResolveContextConcurrently, toPath, tokTypes_1 as tokTypes, trackContext, trackState, transform, transformAndInject, visitStoryboardExpressions, visitStoryboardFunctions };
22873
23067
  //# sourceMappingURL=index.esm.js.map