@next-core/brick-utils 2.32.4 → 2.33.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
@@ -2206,7 +2206,19 @@ function cook(rootAst, codeSource) {
2206
2206
  getRunningContext().LexicalEnvironment = oldEnv;
2207
2207
 
2208
2208
  if (!LoopContinues(result)) {
2209
- return UpdateEmpty(result, V);
2209
+ var status = UpdateEmpty(result, V);
2210
+
2211
+ if (!(iterationKind === "enumerate" || iteratorRecord.return === undefined)) {
2212
+ // Perform *IteratorClose*
2213
+ // https://tc39.es/ecma262/#sec-iteratorclose
2214
+ var innerResult = iteratorRecord.return();
2215
+
2216
+ if (!innerResult || !["object", "function"].includes(typeof innerResult)) {
2217
+ throw new TypeError("Iterator result is not an object");
2218
+ }
2219
+ }
2220
+
2221
+ return status;
2210
2222
  }
2211
2223
 
2212
2224
  if (result.Value !== Empty) {
@@ -3045,62 +3057,15 @@ var lib = {};
3045
3057
  Object.defineProperty(lib, '__esModule', {
3046
3058
  value: true
3047
3059
  });
3048
- var lineBreak = /\r\n?|[\n\u2028\u2029]/;
3049
- var lineBreakG = new RegExp(lineBreak.source, "g");
3050
-
3051
- function isNewLine(code) {
3052
- switch (code) {
3053
- case 10:
3054
- case 13:
3055
- case 8232:
3056
- case 8233:
3057
- return true;
3058
-
3059
- default:
3060
- return false;
3061
- }
3062
- }
3063
-
3064
- var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
3065
- var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
3066
- var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
3067
-
3068
- function isWhitespace(code) {
3069
- switch (code) {
3070
- case 0x0009:
3071
- case 0x000b:
3072
- case 0x000c:
3073
- case 32:
3074
- case 160:
3075
- case 5760:
3076
- case 0x2000:
3077
- case 0x2001:
3078
- case 0x2002:
3079
- case 0x2003:
3080
- case 0x2004:
3081
- case 0x2005:
3082
- case 0x2006:
3083
- case 0x2007:
3084
- case 0x2008:
3085
- case 0x2009:
3086
- case 0x200a:
3087
- case 0x202f:
3088
- case 0x205f:
3089
- case 0x3000:
3090
- case 0xfeff:
3091
- return true;
3092
-
3093
- default:
3094
- return false;
3095
- }
3096
- }
3097
3060
 
3098
3061
  class Position {
3099
- constructor(line, col) {
3062
+ constructor(line, col, index) {
3100
3063
  this.line = void 0;
3101
3064
  this.column = void 0;
3065
+ this.index = void 0;
3102
3066
  this.line = line;
3103
3067
  this.column = col;
3068
+ indexes.set(this, index);
3104
3069
  }
3105
3070
 
3106
3071
  }
@@ -3117,26 +3082,14 @@ class SourceLocation {
3117
3082
 
3118
3083
  }
3119
3084
 
3120
- function getLineInfo(input, offset) {
3121
- var line = 1;
3122
- var lineStart = 0;
3123
- var match;
3124
- lineBreakG.lastIndex = 0;
3125
-
3126
- while ((match = lineBreakG.exec(input)) && match.index < offset) {
3127
- line++;
3128
- lineStart = lineBreakG.lastIndex;
3129
- }
3130
-
3131
- return new Position(line, offset - lineStart);
3132
- }
3085
+ var indexes = new WeakMap();
3133
3086
 
3134
3087
  function createPositionWithColumnOffset(position, columnOffset) {
3135
3088
  var {
3136
3089
  line,
3137
3090
  column
3138
3091
  } = position;
3139
- return new Position(line, column + columnOffset);
3092
+ return new Position(line, column + columnOffset, indexes.get(position) + columnOffset);
3140
3093
  }
3141
3094
 
3142
3095
  class BaseParser {
@@ -3558,13 +3511,7 @@ function makeErrorTemplates(messages, code, syntaxPlugin) {
3558
3511
  }
3559
3512
 
3560
3513
  class ParserError extends CommentsParser {
3561
- getLocationForPosition(pos) {
3562
- var loc;
3563
- if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos);
3564
- return loc;
3565
- }
3566
-
3567
- raise(pos, _ref) {
3514
+ raise(_ref, origin) {
3568
3515
  var {
3569
3516
  code,
3570
3517
  reasonCode,
@@ -3575,13 +3522,13 @@ class ParserError extends CommentsParser {
3575
3522
  params[_key - 2] = arguments[_key];
3576
3523
  }
3577
3524
 
3578
- return this.raiseWithData(pos, {
3525
+ return this.raiseWithData(origin.node ? origin.node.loc.start : origin.at, {
3579
3526
  code,
3580
3527
  reasonCode
3581
3528
  }, template, ...params);
3582
3529
  }
3583
3530
 
3584
- raiseOverwrite(pos, _ref2) {
3531
+ raiseOverwrite(loc, _ref2) {
3585
3532
  var {
3586
3533
  code,
3587
3534
  template
@@ -3591,7 +3538,7 @@ class ParserError extends CommentsParser {
3591
3538
  params[_key2 - 2] = arguments[_key2];
3592
3539
  }
3593
3540
 
3594
- var loc = this.getLocationForPosition(pos);
3541
+ var pos = indexes.get(loc);
3595
3542
  var message = template.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
3596
3543
 
3597
3544
  if (this.options.errorRecovery) {
@@ -3617,12 +3564,12 @@ class ParserError extends CommentsParser {
3617
3564
  }, message);
3618
3565
  }
3619
3566
 
3620
- raiseWithData(pos, data, errorTemplate) {
3567
+ raiseWithData(loc, data, errorTemplate) {
3621
3568
  for (var _len3 = arguments.length, params = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
3622
3569
  params[_key3 - 3] = arguments[_key3];
3623
3570
  }
3624
3571
 
3625
- var loc = this.getLocationForPosition(pos);
3572
+ var pos = indexes.get(loc);
3626
3573
  var message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + " (".concat(loc.line, ":").concat(loc.column, ")");
3627
3574
  return this._raise(Object.assign({
3628
3575
  loc,
@@ -3711,9 +3658,9 @@ var estree = superClass => class extends superClass {
3711
3658
  var expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
3712
3659
  expression.value = directiveLiteral.extra.expressionValue;
3713
3660
  expression.raw = directiveLiteral.extra.raw;
3714
- stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end);
3661
+ stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.loc.end);
3715
3662
  stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
3716
- return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end);
3663
+ return this.finishNodeAt(stmt, "ExpressionStatement", directive.loc.end);
3717
3664
  }
3718
3665
 
3719
3666
  initFunction(node, isAsync) {
@@ -3895,9 +3842,13 @@ var estree = superClass => class extends superClass {
3895
3842
 
3896
3843
  toAssignableObjectExpressionProp(prop) {
3897
3844
  if (prop.kind === "get" || prop.kind === "set") {
3898
- this.raise(prop.key.start, ErrorMessages.PatternHasAccessor);
3845
+ this.raise(ErrorMessages.PatternHasAccessor, {
3846
+ node: prop.key
3847
+ });
3899
3848
  } else if (prop.method) {
3900
- this.raise(prop.key.start, ErrorMessages.PatternHasMethod);
3849
+ this.raise(ErrorMessages.PatternHasMethod, {
3850
+ node: prop.key
3851
+ });
3901
3852
  } else {
3902
3853
  for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
3903
3854
  args[_key5 - 1] = arguments[_key5];
@@ -4568,10 +4519,6 @@ function getExportedToken(token) {
4568
4519
  return tokenTypes[token];
4569
4520
  }
4570
4521
 
4571
- function isTokenType(obj) {
4572
- return typeof obj === "number";
4573
- }
4574
-
4575
4522
  {
4576
4523
  tokenTypes[8].updateContext = context => {
4577
4524
  context.pop();
@@ -4740,7 +4687,6 @@ class ScopeHandler {
4740
4687
  constructor(raise, inModule) {
4741
4688
  this.scopeStack = [];
4742
4689
  this.undefinedExports = new Map();
4743
- this.undefinedPrivateNames = new Map();
4744
4690
  this.raise = raise;
4745
4691
  this.inModule = inModule;
4746
4692
  }
@@ -4806,11 +4752,11 @@ class ScopeHandler {
4806
4752
  return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
4807
4753
  }
4808
4754
 
4809
- declareName(name, bindingType, pos) {
4755
+ declareName(name, bindingType, loc) {
4810
4756
  var scope = this.currentScope();
4811
4757
 
4812
4758
  if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
4813
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
4759
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
4814
4760
 
4815
4761
  if (bindingType & BIND_SCOPE_FUNCTION) {
4816
4762
  scope.functions.add(name);
@@ -4824,7 +4770,7 @@ class ScopeHandler {
4824
4770
  } else if (bindingType & BIND_SCOPE_VAR) {
4825
4771
  for (var i = this.scopeStack.length - 1; i >= 0; --i) {
4826
4772
  scope = this.scopeStack[i];
4827
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
4773
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
4828
4774
  scope.var.add(name);
4829
4775
  this.maybeExportDefined(scope, name);
4830
4776
  if (scope.flags & SCOPE_VAR) break;
@@ -4842,9 +4788,11 @@ class ScopeHandler {
4842
4788
  }
4843
4789
  }
4844
4790
 
4845
- checkRedeclarationInScope(scope, name, bindingType, pos) {
4791
+ checkRedeclarationInScope(scope, name, bindingType, loc) {
4846
4792
  if (this.isRedeclaredInScope(scope, name, bindingType)) {
4847
- this.raise(pos, ErrorMessages.VarRedeclaration, name);
4793
+ this.raise(ErrorMessages.VarRedeclaration, {
4794
+ at: loc
4795
+ }, name);
4848
4796
  }
4849
4797
  }
4850
4798
 
@@ -4869,7 +4817,7 @@ class ScopeHandler {
4869
4817
  var topLevelScope = this.scopeStack[0];
4870
4818
 
4871
4819
  if (!topLevelScope.lexical.has(name) && !topLevelScope.var.has(name) && !topLevelScope.functions.has(name)) {
4872
- this.undefinedExports.set(name, id.start);
4820
+ this.undefinedExports.set(name, id.loc.start);
4873
4821
  }
4874
4822
  }
4875
4823
 
@@ -4916,11 +4864,11 @@ class FlowScopeHandler extends ScopeHandler {
4916
4864
  return new FlowScope(flags);
4917
4865
  }
4918
4866
 
4919
- declareName(name, bindingType, pos) {
4867
+ declareName(name, bindingType, loc) {
4920
4868
  var scope = this.currentScope();
4921
4869
 
4922
4870
  if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
4923
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
4871
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
4924
4872
  this.maybeExportDefined(scope, name);
4925
4873
  scope.declareFunctions.add(name);
4926
4874
  return;
@@ -4947,6 +4895,56 @@ class FlowScopeHandler extends ScopeHandler {
4947
4895
 
4948
4896
  }
4949
4897
 
4898
+ var lineBreak = /\r\n?|[\n\u2028\u2029]/;
4899
+ var lineBreakG = new RegExp(lineBreak.source, "g");
4900
+
4901
+ function isNewLine(code) {
4902
+ switch (code) {
4903
+ case 10:
4904
+ case 13:
4905
+ case 8232:
4906
+ case 8233:
4907
+ return true;
4908
+
4909
+ default:
4910
+ return false;
4911
+ }
4912
+ }
4913
+
4914
+ var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
4915
+ var skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
4916
+ var skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y");
4917
+
4918
+ function isWhitespace(code) {
4919
+ switch (code) {
4920
+ case 0x0009:
4921
+ case 0x000b:
4922
+ case 0x000c:
4923
+ case 32:
4924
+ case 160:
4925
+ case 5760:
4926
+ case 0x2000:
4927
+ case 0x2001:
4928
+ case 0x2002:
4929
+ case 0x2003:
4930
+ case 0x2004:
4931
+ case 0x2005:
4932
+ case 0x2006:
4933
+ case 0x2007:
4934
+ case 0x2008:
4935
+ case 0x2009:
4936
+ case 0x200a:
4937
+ case 0x202f:
4938
+ case 0x205f:
4939
+ case 0x3000:
4940
+ case 0xfeff:
4941
+ return true;
4942
+
4943
+ default:
4944
+ return false;
4945
+ }
4946
+ }
4947
+
4950
4948
  class State {
4951
4949
  constructor() {
4952
4950
  this.strict = void 0;
@@ -4982,7 +4980,6 @@ class State {
4982
4980
  this.lastTokEndLoc = null;
4983
4981
  this.lastTokStartLoc = null;
4984
4982
  this.lastTokStart = 0;
4985
- this.lastTokEnd = 0;
4986
4983
  this.context = [types.brace];
4987
4984
  this.canStartJSXElement = true;
4988
4985
  this.containsEsc = false;
@@ -5000,11 +4997,11 @@ class State {
5000
4997
  this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module";
5001
4998
  this.curLine = startLine;
5002
4999
  this.lineStart = -startColumn;
5003
- this.startLoc = this.endLoc = new Position(startLine, startColumn);
5000
+ this.startLoc = this.endLoc = new Position(startLine, startColumn, 0);
5004
5001
  }
5005
5002
 
5006
5003
  curPosition() {
5007
- return new Position(this.curLine, this.pos - this.lineStart);
5004
+ return new Position(this.curLine, this.pos - this.lineStart, this.pos);
5008
5005
  }
5009
5006
 
5010
5007
  clone(skipArrays) {
@@ -5078,7 +5075,6 @@ class Tokenizer extends ParserError {
5078
5075
  this.pushToken(new Token(this.state));
5079
5076
  }
5080
5077
 
5081
- this.state.lastTokEnd = this.state.end;
5082
5078
  this.state.lastTokStart = this.state.start;
5083
5079
  this.state.lastTokEndLoc = this.state.endLoc;
5084
5080
  this.state.lastTokStartLoc = this.state.startLoc;
@@ -5105,9 +5101,13 @@ class Tokenizer extends ParserError {
5105
5101
  type: state.type,
5106
5102
  start: state.start,
5107
5103
  end: state.end,
5108
- lastTokEnd: state.end,
5109
5104
  context: [this.curContext()],
5110
- inType: state.inType
5105
+ inType: state.inType,
5106
+ startLoc: state.startLoc,
5107
+ lastTokEndLoc: state.lastTokEndLoc,
5108
+ curLine: state.curLine,
5109
+ lineStart: state.lineStart,
5110
+ curPosition: state.curPosition
5111
5111
  };
5112
5112
  }
5113
5113
 
@@ -5153,7 +5153,15 @@ class Tokenizer extends ParserError {
5153
5153
  this.state.strict = strict;
5154
5154
 
5155
5155
  if (strict) {
5156
- this.state.strictErrors.forEach((message, pos) => this.raise(pos, message));
5156
+ this.state.strictErrors.forEach(_ref5 => {
5157
+ var {
5158
+ message,
5159
+ loc
5160
+ } = _ref5;
5161
+ return this.raise(message, {
5162
+ at: loc
5163
+ });
5164
+ });
5157
5165
  this.state.strictErrors.clear();
5158
5166
  }
5159
5167
  }
@@ -5180,7 +5188,13 @@ class Tokenizer extends ParserError {
5180
5188
  if (!this.isLookahead) startLoc = this.state.curPosition();
5181
5189
  var start = this.state.pos;
5182
5190
  var end = this.input.indexOf("*/", start + 2);
5183
- if (end === -1) throw this.raise(start, ErrorMessages.UnterminatedComment);
5191
+
5192
+ if (end === -1) {
5193
+ throw this.raise(ErrorMessages.UnterminatedComment, {
5194
+ at: this.state.curPosition()
5195
+ });
5196
+ }
5197
+
5184
5198
  this.state.pos = end + 2;
5185
5199
  lineBreakG.lastIndex = start + 2;
5186
5200
 
@@ -5338,12 +5352,12 @@ class Tokenizer extends ParserError {
5338
5352
 
5339
5353
  finishToken(type, val) {
5340
5354
  this.state.end = this.state.pos;
5355
+ this.state.endLoc = this.state.curPosition();
5341
5356
  var prevType = this.state.type;
5342
5357
  this.state.type = type;
5343
5358
  this.state.value = val;
5344
5359
 
5345
5360
  if (!this.isLookahead) {
5346
- this.state.endLoc = this.state.curPosition();
5347
5361
  this.updateContext(prevType);
5348
5362
  }
5349
5363
  }
@@ -5362,14 +5376,18 @@ class Tokenizer extends ParserError {
5362
5376
  var next = this.codePointAtPos(nextPos);
5363
5377
 
5364
5378
  if (next >= 48 && next <= 57) {
5365
- throw this.raise(this.state.pos, ErrorMessages.UnexpectedDigitAfterHash);
5379
+ throw this.raise(ErrorMessages.UnexpectedDigitAfterHash, {
5380
+ at: this.state.curPosition()
5381
+ });
5366
5382
  }
5367
5383
 
5368
5384
  if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
5369
5385
  this.expectPlugin("recordAndTuple");
5370
5386
 
5371
5387
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
5372
- throw this.raise(this.state.pos, next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType);
5388
+ throw this.raise(next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType, {
5389
+ at: this.state.curPosition()
5390
+ });
5373
5391
  }
5374
5392
 
5375
5393
  this.state.pos += 2;
@@ -5473,7 +5491,9 @@ class Tokenizer extends ParserError {
5473
5491
 
5474
5492
  if (this.hasPlugin("recordAndTuple") && next === 125) {
5475
5493
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5476
- throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType);
5494
+ throw this.raise(ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType, {
5495
+ at: this.state.curPosition()
5496
+ });
5477
5497
  }
5478
5498
 
5479
5499
  this.state.pos += 2;
@@ -5483,7 +5503,9 @@ class Tokenizer extends ParserError {
5483
5503
 
5484
5504
  if (this.hasPlugin("recordAndTuple") && next === 93) {
5485
5505
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5486
- throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType);
5506
+ throw this.raise(ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType, {
5507
+ at: this.state.curPosition()
5508
+ });
5487
5509
  }
5488
5510
 
5489
5511
  this.state.pos += 2;
@@ -5640,7 +5662,9 @@ class Tokenizer extends ParserError {
5640
5662
  case 91:
5641
5663
  if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
5642
5664
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5643
- throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType);
5665
+ throw this.raise(ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType, {
5666
+ at: this.state.curPosition()
5667
+ });
5644
5668
  }
5645
5669
 
5646
5670
  this.state.pos += 2;
@@ -5660,7 +5684,9 @@ class Tokenizer extends ParserError {
5660
5684
  case 123:
5661
5685
  if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
5662
5686
  if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
5663
- throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType);
5687
+ throw this.raise(ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType, {
5688
+ at: this.state.curPosition()
5689
+ });
5664
5690
  }
5665
5691
 
5666
5692
  this.state.pos += 2;
@@ -5793,7 +5819,9 @@ class Tokenizer extends ParserError {
5793
5819
 
5794
5820
  }
5795
5821
 
5796
- throw this.raise(this.state.pos, ErrorMessages.InvalidOrUnexpectedToken, String.fromCodePoint(code));
5822
+ throw this.raise(ErrorMessages.InvalidOrUnexpectedToken, {
5823
+ at: this.state.curPosition()
5824
+ }, String.fromCodePoint(code));
5797
5825
  }
5798
5826
 
5799
5827
  finishOp(type, size) {
@@ -5803,6 +5831,7 @@ class Tokenizer extends ParserError {
5803
5831
  }
5804
5832
 
5805
5833
  readRegexp() {
5834
+ var startLoc = this.state.startLoc;
5806
5835
  var start = this.state.start + 1;
5807
5836
  var escaped, inClass;
5808
5837
  var {
@@ -5811,13 +5840,17 @@ class Tokenizer extends ParserError {
5811
5840
 
5812
5841
  for (;; ++pos) {
5813
5842
  if (pos >= this.length) {
5814
- throw this.raise(start, ErrorMessages.UnterminatedRegExp);
5843
+ throw this.raise(ErrorMessages.UnterminatedRegExp, {
5844
+ at: createPositionWithColumnOffset(startLoc, 1)
5845
+ });
5815
5846
  }
5816
5847
 
5817
5848
  var ch = this.input.charCodeAt(pos);
5818
5849
 
5819
5850
  if (isNewLine(ch)) {
5820
- throw this.raise(start, ErrorMessages.UnterminatedRegExp);
5851
+ throw this.raise(ErrorMessages.UnterminatedRegExp, {
5852
+ at: createPositionWithColumnOffset(startLoc, 1)
5853
+ });
5821
5854
  }
5822
5855
 
5823
5856
  if (escaped) {
@@ -5845,10 +5878,14 @@ class Tokenizer extends ParserError {
5845
5878
 
5846
5879
  if (VALID_REGEX_FLAGS.has(cp)) {
5847
5880
  if (mods.includes(char)) {
5848
- this.raise(pos + 1, ErrorMessages.DuplicateRegExpFlags);
5881
+ this.raise(ErrorMessages.DuplicateRegExpFlags, {
5882
+ at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
5883
+ });
5849
5884
  }
5850
5885
  } else if (isIdentifierChar(cp) || cp === 92) {
5851
- this.raise(pos + 1, ErrorMessages.MalformedRegExpFlags);
5886
+ this.raise(ErrorMessages.MalformedRegExpFlags, {
5887
+ at: createPositionWithColumnOffset(startLoc, pos + 2 - start)
5888
+ });
5852
5889
  } else {
5853
5890
  break;
5854
5891
  }
@@ -5881,13 +5918,19 @@ class Tokenizer extends ParserError {
5881
5918
  var next = this.input.charCodeAt(this.state.pos + 1);
5882
5919
 
5883
5920
  if (allowedSiblings.indexOf(next) === -1) {
5884
- this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
5921
+ this.raise(ErrorMessages.UnexpectedNumericSeparator, {
5922
+ at: this.state.curPosition()
5923
+ });
5885
5924
  } else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
5886
- this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
5925
+ this.raise(ErrorMessages.UnexpectedNumericSeparator, {
5926
+ at: this.state.curPosition()
5927
+ });
5887
5928
  }
5888
5929
 
5889
5930
  if (!allowNumSeparator) {
5890
- this.raise(this.state.pos, ErrorMessages.NumericSeparatorInEscapeSequence);
5931
+ this.raise(ErrorMessages.NumericSeparatorInEscapeSequence, {
5932
+ at: this.state.curPosition()
5933
+ });
5891
5934
  }
5892
5935
 
5893
5936
  ++this.state.pos;
@@ -5907,7 +5950,9 @@ class Tokenizer extends ParserError {
5907
5950
  if (val >= radix) {
5908
5951
  if (this.options.errorRecovery && val <= 9) {
5909
5952
  val = 0;
5910
- this.raise(this.state.start + i + 2, ErrorMessages.InvalidDigit, radix);
5953
+ this.raise(ErrorMessages.InvalidDigit, {
5954
+ at: this.state.curPosition()
5955
+ }, radix);
5911
5956
  } else if (forceLen) {
5912
5957
  val = 0;
5913
5958
  invalid = true;
@@ -5928,13 +5973,15 @@ class Tokenizer extends ParserError {
5928
5973
  }
5929
5974
 
5930
5975
  readRadixNumber(radix) {
5931
- var start = this.state.pos;
5976
+ var startLoc = this.state.curPosition();
5932
5977
  var isBigInt = false;
5933
5978
  this.state.pos += 2;
5934
5979
  var val = this.readInt(radix);
5935
5980
 
5936
5981
  if (val == null) {
5937
- this.raise(this.state.start + 2, ErrorMessages.InvalidDigit, radix);
5982
+ this.raise(ErrorMessages.InvalidDigit, {
5983
+ at: createPositionWithColumnOffset(startLoc, 2)
5984
+ }, radix);
5938
5985
  }
5939
5986
 
5940
5987
  var next = this.input.charCodeAt(this.state.pos);
@@ -5943,15 +5990,19 @@ class Tokenizer extends ParserError {
5943
5990
  ++this.state.pos;
5944
5991
  isBigInt = true;
5945
5992
  } else if (next === 109) {
5946
- throw this.raise(start, ErrorMessages.InvalidDecimal);
5993
+ throw this.raise(ErrorMessages.InvalidDecimal, {
5994
+ at: startLoc
5995
+ });
5947
5996
  }
5948
5997
 
5949
5998
  if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
5950
- throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
5999
+ throw this.raise(ErrorMessages.NumberIdentifier, {
6000
+ at: this.state.curPosition()
6001
+ });
5951
6002
  }
5952
6003
 
5953
6004
  if (isBigInt) {
5954
- var str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
6005
+ var str = this.input.slice(indexes.get(startLoc), this.state.pos).replace(/[_n]/g, "");
5955
6006
  this.finishToken(127, str);
5956
6007
  return;
5957
6008
  }
@@ -5961,6 +6012,7 @@ class Tokenizer extends ParserError {
5961
6012
 
5962
6013
  readNumber(startsWithDot) {
5963
6014
  var start = this.state.pos;
6015
+ var startLoc = this.state.curPosition();
5964
6016
  var isFloat = false;
5965
6017
  var isBigInt = false;
5966
6018
  var isDecimal = false;
@@ -5968,20 +6020,24 @@ class Tokenizer extends ParserError {
5968
6020
  var isOctal = false;
5969
6021
 
5970
6022
  if (!startsWithDot && this.readInt(10) === null) {
5971
- this.raise(start, ErrorMessages.InvalidNumber);
6023
+ this.raise(ErrorMessages.InvalidNumber, {
6024
+ at: this.state.curPosition()
6025
+ });
5972
6026
  }
5973
6027
 
5974
6028
  var hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
5975
6029
 
5976
6030
  if (hasLeadingZero) {
5977
6031
  var integer = this.input.slice(start, this.state.pos);
5978
- this.recordStrictModeErrors(start, ErrorMessages.StrictOctalLiteral);
6032
+ this.recordStrictModeErrors(ErrorMessages.StrictOctalLiteral, startLoc);
5979
6033
 
5980
6034
  if (!this.state.strict) {
5981
6035
  var underscorePos = integer.indexOf("_");
5982
6036
 
5983
6037
  if (underscorePos > 0) {
5984
- this.raise(underscorePos + start, ErrorMessages.ZeroDigitNumericSeparator);
6038
+ this.raise(ErrorMessages.ZeroDigitNumericSeparator, {
6039
+ at: createPositionWithColumnOffset(startLoc, underscorePos)
6040
+ });
5985
6041
  }
5986
6042
  }
5987
6043
 
@@ -6005,7 +6061,9 @@ class Tokenizer extends ParserError {
6005
6061
  }
6006
6062
 
6007
6063
  if (this.readInt(10) === null) {
6008
- this.raise(start, ErrorMessages.InvalidOrMissingExponent);
6064
+ this.raise(ErrorMessages.InvalidOrMissingExponent, {
6065
+ at: startLoc
6066
+ });
6009
6067
  }
6010
6068
 
6011
6069
  isFloat = true;
@@ -6015,7 +6073,9 @@ class Tokenizer extends ParserError {
6015
6073
 
6016
6074
  if (next === 110) {
6017
6075
  if (isFloat || hasLeadingZero) {
6018
- this.raise(start, ErrorMessages.InvalidBigIntLiteral);
6076
+ this.raise(ErrorMessages.InvalidBigIntLiteral, {
6077
+ at: startLoc
6078
+ });
6019
6079
  }
6020
6080
 
6021
6081
  ++this.state.pos;
@@ -6023,10 +6083,12 @@ class Tokenizer extends ParserError {
6023
6083
  }
6024
6084
 
6025
6085
  if (next === 109) {
6026
- this.expectPlugin("decimal", this.state.pos);
6086
+ this.expectPlugin("decimal", this.state.curPosition());
6027
6087
 
6028
6088
  if (hasExponent || hasLeadingZero) {
6029
- this.raise(start, ErrorMessages.InvalidDecimal);
6089
+ this.raise(ErrorMessages.InvalidDecimal, {
6090
+ at: startLoc
6091
+ });
6030
6092
  }
6031
6093
 
6032
6094
  ++this.state.pos;
@@ -6034,7 +6096,9 @@ class Tokenizer extends ParserError {
6034
6096
  }
6035
6097
 
6036
6098
  if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
6037
- throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
6099
+ throw this.raise(ErrorMessages.NumberIdentifier, {
6100
+ at: this.state.curPosition()
6101
+ });
6038
6102
  }
6039
6103
 
6040
6104
  var str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
@@ -6058,13 +6122,15 @@ class Tokenizer extends ParserError {
6058
6122
  var code;
6059
6123
 
6060
6124
  if (ch === 123) {
6061
- var codePos = ++this.state.pos;
6125
+ ++this.state.pos;
6062
6126
  code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid);
6063
6127
  ++this.state.pos;
6064
6128
 
6065
6129
  if (code !== null && code > 0x10ffff) {
6066
6130
  if (throwOnInvalid) {
6067
- this.raise(codePos, ErrorMessages.InvalidCodePoint);
6131
+ this.raise(ErrorMessages.InvalidCodePoint, {
6132
+ at: this.state.curPosition()
6133
+ });
6068
6134
  } else {
6069
6135
  return null;
6070
6136
  }
@@ -6082,7 +6148,9 @@ class Tokenizer extends ParserError {
6082
6148
 
6083
6149
  for (;;) {
6084
6150
  if (this.state.pos >= this.length) {
6085
- throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
6151
+ throw this.raise(ErrorMessages.UnterminatedString, {
6152
+ at: this.state.startLoc
6153
+ });
6086
6154
  }
6087
6155
 
6088
6156
  var ch = this.input.charCodeAt(this.state.pos);
@@ -6097,7 +6165,9 @@ class Tokenizer extends ParserError {
6097
6165
  ++this.state.curLine;
6098
6166
  this.state.lineStart = this.state.pos;
6099
6167
  } else if (isNewLine(ch)) {
6100
- throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
6168
+ throw this.raise(ErrorMessages.UnterminatedString, {
6169
+ at: this.state.startLoc
6170
+ });
6101
6171
  } else {
6102
6172
  ++this.state.pos;
6103
6173
  }
@@ -6109,7 +6179,7 @@ class Tokenizer extends ParserError {
6109
6179
 
6110
6180
  readTemplateContinuation() {
6111
6181
  if (!this.match(8)) {
6112
- this.unexpected(this.state.start, 8);
6182
+ this.unexpected(null, 8);
6113
6183
  }
6114
6184
 
6115
6185
  this.state.pos--;
@@ -6124,7 +6194,9 @@ class Tokenizer extends ParserError {
6124
6194
 
6125
6195
  for (;;) {
6126
6196
  if (this.state.pos >= this.length) {
6127
- throw this.raise(this.state.start + 1, ErrorMessages.UnterminatedTemplate);
6197
+ throw this.raise(ErrorMessages.UnterminatedTemplate, {
6198
+ at: createPositionWithColumnOffset(this.state.startLoc, 1)
6199
+ });
6128
6200
  }
6129
6201
 
6130
6202
  var ch = this.input.charCodeAt(this.state.pos);
@@ -6182,11 +6254,18 @@ class Tokenizer extends ParserError {
6182
6254
  }
6183
6255
  }
6184
6256
 
6185
- recordStrictModeErrors(pos, message) {
6186
- if (this.state.strict && !this.state.strictErrors.has(pos)) {
6187
- this.raise(pos, message);
6257
+ recordStrictModeErrors(message, loc) {
6258
+ var index = indexes.get(loc);
6259
+
6260
+ if (this.state.strict && !this.state.strictErrors.has(index)) {
6261
+ this.raise(message, {
6262
+ at: loc
6263
+ });
6188
6264
  } else {
6189
- this.state.strictErrors.set(pos, message);
6265
+ this.state.strictErrors.set(index, {
6266
+ loc,
6267
+ message
6268
+ });
6190
6269
  }
6191
6270
  }
6192
6271
 
@@ -6245,12 +6324,12 @@ class Tokenizer extends ParserError {
6245
6324
  if (inTemplate) {
6246
6325
  return null;
6247
6326
  } else {
6248
- this.recordStrictModeErrors(this.state.pos - 1, ErrorMessages.StrictNumericEscape);
6327
+ this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, createPositionWithColumnOffset(this.state.curPosition(), -1));
6249
6328
  }
6250
6329
 
6251
6330
  default:
6252
6331
  if (ch >= 48 && ch <= 55) {
6253
- var codePos = this.state.pos - 1;
6332
+ var codePos = createPositionWithColumnOffset(this.state.curPosition(), -1);
6254
6333
  var match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
6255
6334
  var octalStr = match[0];
6256
6335
  var octal = parseInt(octalStr, 8);
@@ -6267,7 +6346,7 @@ class Tokenizer extends ParserError {
6267
6346
  if (inTemplate) {
6268
6347
  return null;
6269
6348
  } else {
6270
- this.recordStrictModeErrors(codePos, ErrorMessages.StrictNumericEscape);
6349
+ this.recordStrictModeErrors(ErrorMessages.StrictNumericEscape, codePos);
6271
6350
  }
6272
6351
  }
6273
6352
 
@@ -6279,14 +6358,16 @@ class Tokenizer extends ParserError {
6279
6358
  }
6280
6359
 
6281
6360
  readHexChar(len, forceLen, throwOnInvalid) {
6282
- var codePos = this.state.pos;
6361
+ var codeLoc = this.state.curPosition();
6283
6362
  var n = this.readInt(16, len, forceLen, false);
6284
6363
 
6285
6364
  if (n === null) {
6286
6365
  if (throwOnInvalid) {
6287
- this.raise(codePos, ErrorMessages.InvalidEscapeSequence);
6366
+ this.raise(ErrorMessages.InvalidEscapeSequence, {
6367
+ at: codeLoc
6368
+ });
6288
6369
  } else {
6289
- this.state.pos = codePos - 1;
6370
+ this.state.pos = indexes.get(codeLoc) - 1;
6290
6371
  }
6291
6372
  }
6292
6373
 
@@ -6311,11 +6392,13 @@ class Tokenizer extends ParserError {
6311
6392
  } else if (ch === 92) {
6312
6393
  this.state.containsEsc = true;
6313
6394
  word += this.input.slice(chunkStart, this.state.pos);
6314
- var escStart = this.state.pos;
6395
+ var escStart = this.state.curPosition();
6315
6396
  var identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
6316
6397
 
6317
6398
  if (this.input.charCodeAt(++this.state.pos) !== 117) {
6318
- this.raise(this.state.pos, ErrorMessages.MissingUnicodeEscape);
6399
+ this.raise(ErrorMessages.MissingUnicodeEscape, {
6400
+ at: this.state.curPosition()
6401
+ });
6319
6402
  chunkStart = this.state.pos - 1;
6320
6403
  continue;
6321
6404
  }
@@ -6325,7 +6408,9 @@ class Tokenizer extends ParserError {
6325
6408
 
6326
6409
  if (esc !== null) {
6327
6410
  if (!identifierCheck(esc)) {
6328
- this.raise(escStart, ErrorMessages.EscapedCharNotAnIdentifier);
6411
+ this.raise(ErrorMessages.EscapedCharNotAnIdentifier, {
6412
+ at: escStart
6413
+ });
6329
6414
  }
6330
6415
 
6331
6416
  word += String.fromCodePoint(esc);
@@ -6357,7 +6442,9 @@ class Tokenizer extends ParserError {
6357
6442
  } = this.state;
6358
6443
 
6359
6444
  if (tokenIsKeyword(type) && this.state.containsEsc) {
6360
- this.raise(this.state.start, ErrorMessages.InvalidEscapedReservedWord, tokenLabelName(type));
6445
+ this.raise(ErrorMessages.InvalidEscapedReservedWord, {
6446
+ at: this.state.startLoc
6447
+ }, tokenLabelName(type));
6361
6448
  }
6362
6449
  }
6363
6450
 
@@ -6393,18 +6480,20 @@ class ClassScopeHandler {
6393
6480
  var oldClassScope = this.stack.pop();
6394
6481
  var current = this.current();
6395
6482
 
6396
- for (var [name, pos] of Array.from(oldClassScope.undefinedPrivateNames)) {
6483
+ for (var [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) {
6397
6484
  if (current) {
6398
6485
  if (!current.undefinedPrivateNames.has(name)) {
6399
- current.undefinedPrivateNames.set(name, pos);
6486
+ current.undefinedPrivateNames.set(name, loc);
6400
6487
  }
6401
6488
  } else {
6402
- this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
6489
+ this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
6490
+ at: loc
6491
+ }, name);
6403
6492
  }
6404
6493
  }
6405
6494
  }
6406
6495
 
6407
- declarePrivateName(name, elementType, pos) {
6496
+ declarePrivateName(name, elementType, loc) {
6408
6497
  var {
6409
6498
  privateNames,
6410
6499
  loneAccessors,
@@ -6428,14 +6517,16 @@ class ClassScopeHandler {
6428
6517
  }
6429
6518
 
6430
6519
  if (redefined) {
6431
- this.raise(pos, ErrorMessages.PrivateNameRedeclaration, name);
6520
+ this.raise(ErrorMessages.PrivateNameRedeclaration, {
6521
+ at: loc
6522
+ }, name);
6432
6523
  }
6433
6524
 
6434
6525
  privateNames.add(name);
6435
6526
  undefinedPrivateNames.delete(name);
6436
6527
  }
6437
6528
 
6438
- usePrivateName(name, pos) {
6529
+ usePrivateName(name, loc) {
6439
6530
  var classScope;
6440
6531
 
6441
6532
  for (classScope of this.stack) {
@@ -6443,9 +6534,11 @@ class ClassScopeHandler {
6443
6534
  }
6444
6535
 
6445
6536
  if (classScope) {
6446
- classScope.undefinedPrivateNames.set(name, pos);
6537
+ classScope.undefinedPrivateNames.set(name, loc);
6447
6538
  } else {
6448
- this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
6539
+ this.raise(ErrorMessages.InvalidPrivateFieldResolution, {
6540
+ at: loc
6541
+ }, name);
6449
6542
  }
6450
6543
  }
6451
6544
 
@@ -6479,12 +6572,15 @@ class ArrowHeadParsingScope extends ExpressionScope {
6479
6572
  this.errors = new Map();
6480
6573
  }
6481
6574
 
6482
- recordDeclarationError(pos, template) {
6483
- this.errors.set(pos, template);
6575
+ recordDeclarationError(message, loc) {
6576
+ this.errors.set(indexes.get(loc), {
6577
+ message,
6578
+ loc
6579
+ });
6484
6580
  }
6485
6581
 
6486
- clearDeclarationError(pos) {
6487
- this.errors.delete(pos);
6582
+ clearDeclarationError(loc) {
6583
+ this.errors.delete(indexes.get(loc));
6488
6584
  }
6489
6585
 
6490
6586
  iterateErrors(iterator) {
@@ -6507,7 +6603,7 @@ class ExpressionScopeHandler {
6507
6603
  this.stack.pop();
6508
6604
  }
6509
6605
 
6510
- recordParameterInitializerError(pos, template) {
6606
+ recordParameterInitializerError(loc, template) {
6511
6607
  var {
6512
6608
  stack
6513
6609
  } = this;
@@ -6516,7 +6612,7 @@ class ExpressionScopeHandler {
6516
6612
 
6517
6613
  while (!scope.isCertainlyParameterDeclaration()) {
6518
6614
  if (scope.canBeArrowParameterDeclaration()) {
6519
- scope.recordDeclarationError(pos, template);
6615
+ scope.recordDeclarationError(template, loc);
6520
6616
  } else {
6521
6617
  return;
6522
6618
  }
@@ -6524,25 +6620,29 @@ class ExpressionScopeHandler {
6524
6620
  scope = stack[--i];
6525
6621
  }
6526
6622
 
6527
- this.raise(pos, template);
6623
+ this.raise(template, {
6624
+ at: loc
6625
+ });
6528
6626
  }
6529
6627
 
6530
- recordParenthesizedIdentifierError(pos, template) {
6628
+ recordParenthesizedIdentifierError(template, loc) {
6531
6629
  var {
6532
6630
  stack
6533
6631
  } = this;
6534
6632
  var scope = stack[stack.length - 1];
6535
6633
 
6536
6634
  if (scope.isCertainlyParameterDeclaration()) {
6537
- this.raise(pos, template);
6635
+ this.raise(template, {
6636
+ at: loc
6637
+ });
6538
6638
  } else if (scope.canBeArrowParameterDeclaration()) {
6539
- scope.recordDeclarationError(pos, template);
6639
+ scope.recordDeclarationError(template, loc);
6540
6640
  } else {
6541
6641
  return;
6542
6642
  }
6543
6643
  }
6544
6644
 
6545
- recordAsyncArrowParametersError(pos, template) {
6645
+ recordAsyncArrowParametersError(template, loc) {
6546
6646
  var {
6547
6647
  stack
6548
6648
  } = this;
@@ -6551,7 +6651,7 @@ class ExpressionScopeHandler {
6551
6651
 
6552
6652
  while (scope.canBeArrowParameterDeclaration()) {
6553
6653
  if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
6554
- scope.recordDeclarationError(pos, template);
6654
+ scope.recordDeclarationError(template, loc);
6555
6655
  }
6556
6656
 
6557
6657
  scope = stack[--i];
@@ -6564,13 +6664,19 @@ class ExpressionScopeHandler {
6564
6664
  } = this;
6565
6665
  var currentScope = stack[stack.length - 1];
6566
6666
  if (!currentScope.canBeArrowParameterDeclaration()) return;
6567
- currentScope.iterateErrors((template, pos) => {
6568
- this.raise(pos, template);
6667
+ currentScope.iterateErrors(_ref6 => {
6668
+ var {
6669
+ message,
6670
+ loc
6671
+ } = _ref6;
6672
+ this.raise(message, {
6673
+ at: loc
6674
+ });
6569
6675
  var i = stack.length - 2;
6570
6676
  var scope = stack[i];
6571
6677
 
6572
6678
  while (scope.canBeArrowParameterDeclaration()) {
6573
- scope.clearDeclarationError(pos);
6679
+ scope.clearDeclarationError(loc);
6574
6680
  scope = stack[--i];
6575
6681
  }
6576
6682
  });
@@ -6640,10 +6746,19 @@ function functionFlags(isAsync, isGenerator) {
6640
6746
  }
6641
6747
 
6642
6748
  class UtilParser extends Tokenizer {
6643
- addExtra(node, key, val) {
6749
+ addExtra(node, key, value) {
6750
+ var enumerable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
6644
6751
  if (!node) return;
6645
6752
  var extra = node.extra = node.extra || {};
6646
- extra[key] = val;
6753
+
6754
+ if (enumerable) {
6755
+ extra[key] = value;
6756
+ } else {
6757
+ Object.defineProperty(extra, key, {
6758
+ enumerable,
6759
+ value
6760
+ });
6761
+ }
6647
6762
  }
6648
6763
 
6649
6764
  isContextual(token) {
@@ -6676,7 +6791,15 @@ class UtilParser extends Tokenizer {
6676
6791
  }
6677
6792
 
6678
6793
  expectContextual(token, template) {
6679
- if (!this.eatContextual(token)) this.unexpected(null, template);
6794
+ if (!this.eatContextual(token)) {
6795
+ if (template != null) {
6796
+ throw this.raise(template, {
6797
+ at: this.state.startLoc
6798
+ });
6799
+ }
6800
+
6801
+ throw this.unexpected(null, token);
6802
+ }
6680
6803
  }
6681
6804
 
6682
6805
  canInsertSemicolon() {
@@ -6684,7 +6807,7 @@ class UtilParser extends Tokenizer {
6684
6807
  }
6685
6808
 
6686
6809
  hasPrecedingLineBreak() {
6687
- return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
6810
+ return lineBreak.test(this.input.slice(indexes.get(this.state.lastTokEndLoc), this.state.start));
6688
6811
  }
6689
6812
 
6690
6813
  hasFollowingLineBreak() {
@@ -6699,41 +6822,37 @@ class UtilParser extends Tokenizer {
6699
6822
  semicolon() {
6700
6823
  var allowAsi = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6701
6824
  if (allowAsi ? this.isLineTerminator() : this.eat(13)) return;
6702
- this.raise(this.state.lastTokEnd, ErrorMessages.MissingSemicolon);
6825
+ this.raise(ErrorMessages.MissingSemicolon, {
6826
+ at: this.state.lastTokEndLoc
6827
+ });
6703
6828
  }
6704
6829
 
6705
- expect(type, pos) {
6706
- this.eat(type) || this.unexpected(pos, type);
6830
+ expect(type, loc) {
6831
+ this.eat(type) || this.unexpected(loc, type);
6707
6832
  }
6708
6833
 
6709
6834
  assertNoSpace() {
6710
6835
  var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "Unexpected space.";
6711
6836
 
6712
- if (this.state.start > this.state.lastTokEnd) {
6713
- this.raise(this.state.lastTokEnd, {
6837
+ if (this.state.start > indexes.get(this.state.lastTokEndLoc)) {
6838
+ this.raise({
6714
6839
  code: ErrorCodes.SyntaxError,
6715
6840
  reasonCode: "UnexpectedSpace",
6716
6841
  template: message
6842
+ }, {
6843
+ at: this.state.lastTokEndLoc
6717
6844
  });
6718
6845
  }
6719
6846
  }
6720
6847
 
6721
- unexpected(pos) {
6722
- var messageOrType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
6848
+ unexpected(loc, type) {
6849
+ throw this.raise({
6723
6850
  code: ErrorCodes.SyntaxError,
6724
6851
  reasonCode: "UnexpectedToken",
6725
- template: "Unexpected token"
6726
- };
6727
-
6728
- if (isTokenType(messageOrType)) {
6729
- messageOrType = {
6730
- code: ErrorCodes.SyntaxError,
6731
- reasonCode: "UnexpectedToken",
6732
- template: "Unexpected token, expected \"".concat(tokenLabelName(messageOrType), "\"")
6733
- };
6734
- }
6735
-
6736
- throw this.raise(pos != null ? pos : this.state.start, messageOrType);
6852
+ template: type != null ? "Unexpected token, expected \"".concat(tokenLabelName(type), "\"") : "Unexpected token"
6853
+ }, {
6854
+ at: loc != null ? loc : this.state.startLoc
6855
+ });
6737
6856
  }
6738
6857
 
6739
6858
  getPluginNamesFromConfigs(pluginConfigs) {
@@ -6746,9 +6865,9 @@ class UtilParser extends Tokenizer {
6746
6865
  });
6747
6866
  }
6748
6867
 
6749
- expectPlugin(pluginConfig, pos) {
6868
+ expectPlugin(pluginConfig, loc) {
6750
6869
  if (!this.hasPlugin(pluginConfig)) {
6751
- throw this.raiseWithData(pos != null ? pos : this.state.start, {
6870
+ throw this.raiseWithData(loc != null ? loc : this.state.startLoc, {
6752
6871
  missingPlugin: this.getPluginNamesFromConfigs([pluginConfig])
6753
6872
  }, "This experimental syntax requires enabling the parser plugin: ".concat(JSON.stringify(pluginConfig), "."));
6754
6873
  }
@@ -6756,9 +6875,9 @@ class UtilParser extends Tokenizer {
6756
6875
  return true;
6757
6876
  }
6758
6877
 
6759
- expectOnePlugin(pluginConfigs, pos) {
6878
+ expectOnePlugin(pluginConfigs) {
6760
6879
  if (!pluginConfigs.some(c => this.hasPlugin(c))) {
6761
- throw this.raiseWithData(pos != null ? pos : this.state.start, {
6880
+ throw this.raiseWithData(this.state.startLoc, {
6762
6881
  missingPlugin: this.getPluginNamesFromConfigs(pluginConfigs)
6763
6882
  }, "This experimental syntax requires enabling one of the following parser plugin(s): ".concat(pluginConfigs.map(c => JSON.stringify(c)).join(", "), "."));
6764
6883
  }
@@ -6828,26 +6947,30 @@ class UtilParser extends Tokenizer {
6828
6947
  checkExpressionErrors(refExpressionErrors, andThrow) {
6829
6948
  if (!refExpressionErrors) return false;
6830
6949
  var {
6831
- shorthandAssign,
6832
- doubleProto,
6833
- optionalParameters
6950
+ shorthandAssignLoc,
6951
+ doubleProtoLoc,
6952
+ optionalParametersLoc
6834
6953
  } = refExpressionErrors;
6835
- var hasErrors = shorthandAssign + doubleProto + optionalParameters > -3;
6954
+ var hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc;
6836
6955
 
6837
6956
  if (!andThrow) {
6838
6957
  return hasErrors;
6839
- } else if (hasErrors) {
6840
- if (shorthandAssign >= 0) {
6841
- this.raise(shorthandAssign, ErrorMessages.InvalidCoverInitializedName);
6842
- }
6958
+ }
6843
6959
 
6844
- if (doubleProto >= 0) {
6845
- this.raise(doubleProto, ErrorMessages.DuplicateProto);
6846
- }
6960
+ if (shorthandAssignLoc != null) {
6961
+ this.raise(ErrorMessages.InvalidCoverInitializedName, {
6962
+ at: shorthandAssignLoc
6963
+ });
6964
+ }
6847
6965
 
6848
- if (optionalParameters >= 0) {
6849
- this.unexpected(optionalParameters);
6850
- }
6966
+ if (doubleProtoLoc != null) {
6967
+ this.raise(ErrorMessages.DuplicateProto, {
6968
+ at: doubleProtoLoc
6969
+ });
6970
+ }
6971
+
6972
+ if (optionalParametersLoc != null) {
6973
+ this.unexpected(optionalParametersLoc);
6851
6974
  }
6852
6975
  }
6853
6976
 
@@ -6922,9 +7045,9 @@ class UtilParser extends Tokenizer {
6922
7045
 
6923
7046
  class ExpressionErrors {
6924
7047
  constructor() {
6925
- this.shorthandAssign = -1;
6926
- this.doubleProto = -1;
6927
- this.optionalParameters = -1;
7048
+ this.shorthandAssignLoc = null;
7049
+ this.doubleProtoLoc = null;
7050
+ this.optionalParametersLoc = null;
6928
7051
  }
6929
7052
 
6930
7053
  }
@@ -7034,14 +7157,14 @@ class NodeUtils extends UtilParser {
7034
7157
  }
7035
7158
 
7036
7159
  finishNode(node, type) {
7037
- return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc);
7160
+ return this.finishNodeAt(node, type, this.state.lastTokEndLoc);
7038
7161
  }
7039
7162
 
7040
- finishNodeAt(node, type, pos, loc) {
7163
+ finishNodeAt(node, type, endLoc) {
7041
7164
  node.type = type;
7042
- node.end = pos;
7043
- node.loc.end = loc;
7044
- if (this.options.ranges) node.range[1] = pos;
7165
+ node.end = indexes.get(endLoc);
7166
+ node.loc.end = endLoc;
7167
+ if (this.options.ranges) node.range[1] = node.end;
7045
7168
  if (this.options.attachComment) this.processComment(node);
7046
7169
  return node;
7047
7170
  }
@@ -7053,11 +7176,10 @@ class NodeUtils extends UtilParser {
7053
7176
  }
7054
7177
 
7055
7178
  resetEndLocation(node) {
7056
- var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEnd;
7057
- var endLoc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.state.lastTokEndLoc;
7058
- node.end = end;
7179
+ var endLoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.state.lastTokEndLoc;
7180
+ node.end = indexes.get(endLoc);
7059
7181
  node.loc.end = endLoc;
7060
- if (this.options.ranges) node.range[1] = end;
7182
+ if (this.options.ranges) node.range[1] = node.end;
7061
7183
  }
7062
7184
 
7063
7185
  resetStartLocationFromNode(node, locationNode) {
@@ -7203,12 +7325,14 @@ var flow = superClass => class extends superClass {
7203
7325
 
7204
7326
  flowParsePredicate() {
7205
7327
  var node = this.startNode();
7206
- var moduloPos = this.state.start;
7328
+ var moduloLoc = this.state.startLoc;
7207
7329
  this.next();
7208
7330
  this.expectContextual(103);
7209
7331
 
7210
- if (this.state.lastTokStart > moduloPos + 1) {
7211
- this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks);
7332
+ if (this.state.lastTokStart > indexes.get(moduloLoc) + 1) {
7333
+ this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, {
7334
+ at: moduloLoc
7335
+ });
7212
7336
  }
7213
7337
 
7214
7338
  if (this.eat(10)) {
@@ -7271,7 +7395,7 @@ var flow = superClass => class extends superClass {
7271
7395
  id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
7272
7396
  this.resetEndLocation(id);
7273
7397
  this.semicolon();
7274
- this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.start);
7398
+ this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.loc.start);
7275
7399
  return this.finishNode(node, "DeclareFunction");
7276
7400
  }
7277
7401
 
@@ -7287,7 +7411,9 @@ var flow = superClass => class extends superClass {
7287
7411
  return this.flowParseDeclareModuleExports(node);
7288
7412
  } else {
7289
7413
  if (insideModule) {
7290
- this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule);
7414
+ this.raise(FlowErrors.NestedDeclareModule, {
7415
+ at: this.state.lastTokStartLoc
7416
+ });
7291
7417
  }
7292
7418
 
7293
7419
  return this.flowParseDeclareModule(node);
@@ -7308,7 +7434,7 @@ var flow = superClass => class extends superClass {
7308
7434
  flowParseDeclareVariable(node) {
7309
7435
  this.next();
7310
7436
  node.id = this.flowParseTypeAnnotatableIdentifier(true);
7311
- this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
7437
+ this.scope.declareName(node.id.name, BIND_VAR, node.id.loc.start);
7312
7438
  this.semicolon();
7313
7439
  return this.finishNode(node, "DeclareVariable");
7314
7440
  }
@@ -7333,7 +7459,9 @@ var flow = superClass => class extends superClass {
7333
7459
  this.next();
7334
7460
 
7335
7461
  if (!this.isContextual(122) && !this.match(83)) {
7336
- this.raise(this.state.lastTokStart, FlowErrors.InvalidNonTypeImportInDeclareModule);
7462
+ this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, {
7463
+ at: this.state.lastTokStartLoc
7464
+ });
7337
7465
  }
7338
7466
 
7339
7467
  this.parseImport(_bodyNode);
@@ -7353,17 +7481,23 @@ var flow = superClass => class extends superClass {
7353
7481
  body.forEach(bodyElement => {
7354
7482
  if (isEsModuleType(bodyElement)) {
7355
7483
  if (kind === "CommonJS") {
7356
- this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
7484
+ this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
7485
+ node: bodyElement
7486
+ });
7357
7487
  }
7358
7488
 
7359
7489
  kind = "ES";
7360
7490
  } else if (bodyElement.type === "DeclareModuleExports") {
7361
7491
  if (hasModuleExport) {
7362
- this.raise(bodyElement.start, FlowErrors.DuplicateDeclareModuleExports);
7492
+ this.raise(FlowErrors.DuplicateDeclareModuleExports, {
7493
+ node: bodyElement
7494
+ });
7363
7495
  }
7364
7496
 
7365
7497
  if (kind === "ES") {
7366
- this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
7498
+ this.raise(FlowErrors.AmbiguousDeclareModuleKind, {
7499
+ node: bodyElement
7500
+ });
7367
7501
  }
7368
7502
 
7369
7503
  kind = "CommonJS";
@@ -7391,7 +7525,9 @@ var flow = superClass => class extends superClass {
7391
7525
  if (this.match(71) || this.isLet() || (this.isContextual(122) || this.isContextual(121)) && !insideModule) {
7392
7526
  var label = this.state.value;
7393
7527
  var suggestion = exportSuggestions[label];
7394
- throw this.raise(this.state.start, FlowErrors.UnsupportedDeclareExportKind, label, suggestion);
7528
+ throw this.raise(FlowErrors.UnsupportedDeclareExportKind, {
7529
+ at: this.state.startLoc
7530
+ }, label, suggestion);
7395
7531
  }
7396
7532
 
7397
7533
  if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(123)) {
@@ -7446,7 +7582,7 @@ var flow = superClass => class extends superClass {
7446
7582
  flowParseInterfaceish(node) {
7447
7583
  var isClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7448
7584
  node.id = this.flowParseRestrictedIdentifier(!isClass, true);
7449
- this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start);
7585
+ this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.loc.start);
7450
7586
 
7451
7587
  if (this.match(45)) {
7452
7588
  node.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -7509,23 +7645,27 @@ var flow = superClass => class extends superClass {
7509
7645
 
7510
7646
  checkNotUnderscore(word) {
7511
7647
  if (word === "_") {
7512
- this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore);
7648
+ this.raise(FlowErrors.UnexpectedReservedUnderscore, {
7649
+ at: this.state.startLoc
7650
+ });
7513
7651
  }
7514
7652
  }
7515
7653
 
7516
7654
  checkReservedType(word, startLoc, declaration) {
7517
7655
  if (!reservedTypes.has(word)) return;
7518
- this.raise(startLoc, declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, word);
7656
+ this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, {
7657
+ at: startLoc
7658
+ }, word);
7519
7659
  }
7520
7660
 
7521
7661
  flowParseRestrictedIdentifier(liberal, declaration) {
7522
- this.checkReservedType(this.state.value, this.state.start, declaration);
7662
+ this.checkReservedType(this.state.value, this.state.startLoc, declaration);
7523
7663
  return this.parseIdentifier(liberal);
7524
7664
  }
7525
7665
 
7526
7666
  flowParseTypeAlias(node) {
7527
7667
  node.id = this.flowParseRestrictedIdentifier(false, true);
7528
- this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
7668
+ this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
7529
7669
 
7530
7670
  if (this.match(45)) {
7531
7671
  node.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -7541,7 +7681,7 @@ var flow = superClass => class extends superClass {
7541
7681
  flowParseOpaqueType(node, declare) {
7542
7682
  this.expectContextual(122);
7543
7683
  node.id = this.flowParseRestrictedIdentifier(true, true);
7544
- this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
7684
+ this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.loc.start);
7545
7685
 
7546
7686
  if (this.match(45)) {
7547
7687
  node.typeParameters = this.flowParseTypeParameterDeclaration();
@@ -7567,7 +7707,7 @@ var flow = superClass => class extends superClass {
7567
7707
 
7568
7708
  flowParseTypeParameter() {
7569
7709
  var requireDefault = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7570
- var nodeStart = this.state.start;
7710
+ var nodeStartLoc = this.state.startLoc;
7571
7711
  var node = this.startNode();
7572
7712
  var variance = this.flowParseVariance();
7573
7713
  var ident = this.flowParseTypeAnnotatableIdentifier();
@@ -7580,7 +7720,9 @@ var flow = superClass => class extends superClass {
7580
7720
  node.default = this.flowParseType();
7581
7721
  } else {
7582
7722
  if (requireDefault) {
7583
- this.raise(nodeStart, FlowErrors.MissingTypeParamDefault);
7723
+ this.raise(FlowErrors.MissingTypeParamDefault, {
7724
+ at: nodeStartLoc
7725
+ });
7584
7726
  }
7585
7727
  }
7586
7728
 
@@ -7772,14 +7914,14 @@ var flow = superClass => class extends superClass {
7772
7914
  return this.finishNode(node, "ObjectTypeCallProperty");
7773
7915
  }
7774
7916
 
7775
- flowParseObjectType(_ref5) {
7917
+ flowParseObjectType(_ref7) {
7776
7918
  var {
7777
7919
  allowStatic,
7778
7920
  allowExact,
7779
7921
  allowSpread,
7780
7922
  allowProto,
7781
7923
  allowInexact
7782
- } = _ref5;
7924
+ } = _ref7;
7783
7925
  var oldInType = this.state.inType;
7784
7926
  this.state.inType = true;
7785
7927
  var nodeStart = this.startNode();
@@ -7805,8 +7947,8 @@ var flow = superClass => class extends superClass {
7805
7947
 
7806
7948
  while (!this.match(endDelim)) {
7807
7949
  var isStatic = false;
7808
- var protoStart = null;
7809
- var inexactStart = null;
7950
+ var protoStartLoc = null;
7951
+ var inexactStartLoc = null;
7810
7952
  var node = this.startNode();
7811
7953
 
7812
7954
  if (allowProto && this.isContextual(111)) {
@@ -7814,7 +7956,7 @@ var flow = superClass => class extends superClass {
7814
7956
 
7815
7957
  if (lookahead.type !== 14 && lookahead.type !== 17) {
7816
7958
  this.next();
7817
- protoStart = this.state.start;
7959
+ protoStartLoc = this.state.startLoc;
7818
7960
  allowStatic = false;
7819
7961
  }
7820
7962
  }
@@ -7831,13 +7973,13 @@ var flow = superClass => class extends superClass {
7831
7973
  var variance = this.flowParseVariance();
7832
7974
 
7833
7975
  if (this.eat(0)) {
7834
- if (protoStart != null) {
7835
- this.unexpected(protoStart);
7976
+ if (protoStartLoc != null) {
7977
+ this.unexpected(protoStartLoc);
7836
7978
  }
7837
7979
 
7838
7980
  if (this.eat(0)) {
7839
7981
  if (variance) {
7840
- this.unexpected(variance.start);
7982
+ this.unexpected(variance.loc.start);
7841
7983
  }
7842
7984
 
7843
7985
  nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
@@ -7845,12 +7987,12 @@ var flow = superClass => class extends superClass {
7845
7987
  nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
7846
7988
  }
7847
7989
  } else if (this.match(10) || this.match(45)) {
7848
- if (protoStart != null) {
7849
- this.unexpected(protoStart);
7990
+ if (protoStartLoc != null) {
7991
+ this.unexpected(protoStartLoc);
7850
7992
  }
7851
7993
 
7852
7994
  if (variance) {
7853
- this.unexpected(variance.start);
7995
+ this.unexpected(variance.loc.start);
7854
7996
  }
7855
7997
 
7856
7998
  nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
@@ -7866,11 +8008,11 @@ var flow = superClass => class extends superClass {
7866
8008
  }
7867
8009
  }
7868
8010
 
7869
- var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
8011
+ var propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
7870
8012
 
7871
8013
  if (propOrInexact === null) {
7872
8014
  inexact = true;
7873
- inexactStart = this.state.lastTokStart;
8015
+ inexactStartLoc = this.state.lastTokStartLoc;
7874
8016
  } else {
7875
8017
  nodeStart.properties.push(propOrInexact);
7876
8018
  }
@@ -7878,8 +8020,10 @@ var flow = superClass => class extends superClass {
7878
8020
 
7879
8021
  this.flowObjectTypeSemicolon();
7880
8022
 
7881
- if (inexactStart && !this.match(8) && !this.match(9)) {
7882
- this.raise(inexactStart, FlowErrors.UnexpectedExplicitInexactInObject);
8023
+ if (inexactStartLoc && !this.match(8) && !this.match(9)) {
8024
+ this.raise(FlowErrors.UnexpectedExplicitInexactInObject, {
8025
+ at: inexactStartLoc
8026
+ });
7883
8027
  }
7884
8028
  }
7885
8029
 
@@ -7894,34 +8038,44 @@ var flow = superClass => class extends superClass {
7894
8038
  return out;
7895
8039
  }
7896
8040
 
7897
- flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) {
8041
+ flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) {
7898
8042
  if (this.eat(21)) {
7899
8043
  var isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9);
7900
8044
 
7901
8045
  if (isInexactToken) {
7902
8046
  if (!allowSpread) {
7903
- this.raise(this.state.lastTokStart, FlowErrors.InexactInsideNonObject);
8047
+ this.raise(FlowErrors.InexactInsideNonObject, {
8048
+ at: this.state.lastTokStartLoc
8049
+ });
7904
8050
  } else if (!allowInexact) {
7905
- this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact);
8051
+ this.raise(FlowErrors.InexactInsideExact, {
8052
+ at: this.state.lastTokStartLoc
8053
+ });
7906
8054
  }
7907
8055
 
7908
8056
  if (variance) {
7909
- this.raise(variance.start, FlowErrors.InexactVariance);
8057
+ this.raise(FlowErrors.InexactVariance, {
8058
+ node: variance
8059
+ });
7910
8060
  }
7911
8061
 
7912
8062
  return null;
7913
8063
  }
7914
8064
 
7915
8065
  if (!allowSpread) {
7916
- this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType);
8066
+ this.raise(FlowErrors.UnexpectedSpreadType, {
8067
+ at: this.state.lastTokStartLoc
8068
+ });
7917
8069
  }
7918
8070
 
7919
- if (protoStart != null) {
7920
- this.unexpected(protoStart);
8071
+ if (protoStartLoc != null) {
8072
+ this.unexpected(protoStartLoc);
7921
8073
  }
7922
8074
 
7923
8075
  if (variance) {
7924
- this.raise(variance.start, FlowErrors.SpreadVariance);
8076
+ this.raise(FlowErrors.SpreadVariance, {
8077
+ node: variance
8078
+ });
7925
8079
  }
7926
8080
 
7927
8081
  node.argument = this.flowParseType();
@@ -7929,19 +8083,19 @@ var flow = superClass => class extends superClass {
7929
8083
  } else {
7930
8084
  node.key = this.flowParseObjectPropertyKey();
7931
8085
  node.static = isStatic;
7932
- node.proto = protoStart != null;
8086
+ node.proto = protoStartLoc != null;
7933
8087
  node.kind = kind;
7934
8088
  var optional = false;
7935
8089
 
7936
8090
  if (this.match(45) || this.match(10)) {
7937
8091
  node.method = true;
7938
8092
 
7939
- if (protoStart != null) {
7940
- this.unexpected(protoStart);
8093
+ if (protoStartLoc != null) {
8094
+ this.unexpected(protoStartLoc);
7941
8095
  }
7942
8096
 
7943
8097
  if (variance) {
7944
- this.unexpected(variance.start);
8098
+ this.unexpected(variance.loc.start);
7945
8099
  }
7946
8100
 
7947
8101
  node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
@@ -7951,7 +8105,9 @@ var flow = superClass => class extends superClass {
7951
8105
  }
7952
8106
 
7953
8107
  if (!allowSpread && node.key.name === "constructor" && node.value.this) {
7954
- this.raise(node.value.this.start, FlowErrors.ThisParamBannedInConstructor);
8108
+ this.raise(FlowErrors.ThisParamBannedInConstructor, {
8109
+ node: node.value.this
8110
+ });
7955
8111
  }
7956
8112
  } else {
7957
8113
  if (kind !== "init") this.unexpected();
@@ -7972,23 +8128,24 @@ var flow = superClass => class extends superClass {
7972
8128
 
7973
8129
  flowCheckGetterSetterParams(property) {
7974
8130
  var paramCount = property.kind === "get" ? 0 : 1;
7975
- var start = property.start;
7976
8131
  var length = property.value.params.length + (property.value.rest ? 1 : 0);
7977
8132
 
7978
8133
  if (property.value.this) {
7979
- this.raise(property.value.this.start, property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam);
8134
+ this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, {
8135
+ node: property.value.this
8136
+ });
7980
8137
  }
7981
8138
 
7982
8139
  if (length !== paramCount) {
7983
- if (property.kind === "get") {
7984
- this.raise(start, ErrorMessages.BadGetterArity);
7985
- } else {
7986
- this.raise(start, ErrorMessages.BadSetterArity);
7987
- }
8140
+ this.raise(property.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
8141
+ node: property
8142
+ });
7988
8143
  }
7989
8144
 
7990
8145
  if (property.kind === "set" && property.value.rest) {
7991
- this.raise(start, ErrorMessages.BadSetterRestParameter);
8146
+ this.raise(ErrorMessages.BadSetterRestParameter, {
8147
+ node: property
8148
+ });
7992
8149
  }
7993
8150
  }
7994
8151
 
@@ -8057,7 +8214,9 @@ var flow = superClass => class extends superClass {
8057
8214
 
8058
8215
  if (lh.type === 14 || lh.type === 17) {
8059
8216
  if (isThis && !first) {
8060
- this.raise(node.start, FlowErrors.ThisParamMustBeFirst);
8217
+ this.raise(FlowErrors.ThisParamMustBeFirst, {
8218
+ node
8219
+ });
8061
8220
  }
8062
8221
 
8063
8222
  name = this.parseIdentifier(isThis);
@@ -8066,7 +8225,9 @@ var flow = superClass => class extends superClass {
8066
8225
  optional = true;
8067
8226
 
8068
8227
  if (isThis) {
8069
- this.raise(node.start, FlowErrors.ThisParamMayNotBeOptional);
8228
+ this.raise(FlowErrors.ThisParamMayNotBeOptional, {
8229
+ node
8230
+ });
8070
8231
  }
8071
8232
  }
8072
8233
 
@@ -8259,7 +8420,9 @@ var flow = superClass => class extends superClass {
8259
8420
  return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
8260
8421
  }
8261
8422
 
8262
- throw this.raise(this.state.start, FlowErrors.UnexpectedSubtractionOperand);
8423
+ throw this.raise(FlowErrors.UnexpectedSubtractionOperand, {
8424
+ at: this.state.startLoc
8425
+ });
8263
8426
  }
8264
8427
 
8265
8428
  throw this.unexpected();
@@ -8431,7 +8594,7 @@ var flow = superClass => class extends superClass {
8431
8594
 
8432
8595
  typeCastToParameter(node) {
8433
8596
  node.expression.typeAnnotation = node.typeAnnotation;
8434
- this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
8597
+ this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
8435
8598
  return node.expression;
8436
8599
  }
8437
8600
 
@@ -8596,7 +8759,9 @@ var flow = superClass => class extends superClass {
8596
8759
  }
8597
8760
 
8598
8761
  if (failed && valid.length > 1) {
8599
- this.raise(state.start, FlowErrors.AmbiguousConditionalArrow);
8762
+ this.raise(FlowErrors.AmbiguousConditionalArrow, {
8763
+ at: state.startLoc
8764
+ });
8600
8765
  }
8601
8766
 
8602
8767
  if (failed && valid.length === 1) {
@@ -8662,7 +8827,7 @@ var flow = superClass => class extends superClass {
8662
8827
  finishArrowValidation(node) {
8663
8828
  var _node$extra;
8664
8829
 
8665
- this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma, false);
8830
+ this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false);
8666
8831
  this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
8667
8832
  super.checkParams(node, false, true);
8668
8833
  this.scope.exit();
@@ -8771,11 +8936,13 @@ var flow = superClass => class extends superClass {
8771
8936
  }
8772
8937
 
8773
8938
  maybeParseExportNamespaceSpecifier(node) {
8774
- var pos = this.state.start;
8939
+ var {
8940
+ startLoc
8941
+ } = this.state;
8775
8942
  var hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
8776
8943
 
8777
8944
  if (hasNamespace && node.exportKind === "type") {
8778
- this.unexpected(pos);
8945
+ this.unexpected(startLoc);
8779
8946
  }
8780
8947
 
8781
8948
  return hasNamespace;
@@ -8790,7 +8957,9 @@ var flow = superClass => class extends superClass {
8790
8957
  }
8791
8958
 
8792
8959
  parseClassMember(classBody, member, state) {
8793
- var pos = this.state.start;
8960
+ var {
8961
+ startLoc
8962
+ } = this.state;
8794
8963
 
8795
8964
  if (this.isContextual(117)) {
8796
8965
  if (this.parseClassMemberFromModifier(classBody, member)) {
@@ -8804,9 +8973,13 @@ var flow = superClass => class extends superClass {
8804
8973
 
8805
8974
  if (member.declare) {
8806
8975
  if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
8807
- this.raise(pos, FlowErrors.DeclareClassElement);
8976
+ this.raise(FlowErrors.DeclareClassElement, {
8977
+ at: startLoc
8978
+ });
8808
8979
  } else if (member.value) {
8809
- this.raise(member.value.start, FlowErrors.DeclareClassFieldInitializer);
8980
+ this.raise(FlowErrors.DeclareClassFieldInitializer, {
8981
+ node: member.value
8982
+ });
8810
8983
  }
8811
8984
  }
8812
8985
  }
@@ -8820,7 +8993,9 @@ var flow = superClass => class extends superClass {
8820
8993
  var fullWord = "@@" + word;
8821
8994
 
8822
8995
  if (!this.isIterator(word) || !this.state.inType) {
8823
- this.raise(this.state.pos, ErrorMessages.InvalidIdentifier, fullWord);
8996
+ this.raise(ErrorMessages.InvalidIdentifier, {
8997
+ at: this.state.curPosition()
8998
+ }, fullWord);
8824
8999
  }
8825
9000
 
8826
9001
  this.finishToken(124, fullWord);
@@ -8865,7 +9040,7 @@ var flow = superClass => class extends superClass {
8865
9040
  }
8866
9041
  }
8867
9042
 
8868
- toAssignableList(exprList, trailingCommaPos, isLHS) {
9043
+ toAssignableList(exprList, trailingCommaLoc, isLHS) {
8869
9044
  for (var i = 0; i < exprList.length; i++) {
8870
9045
  var expr = exprList[i];
8871
9046
 
@@ -8874,7 +9049,7 @@ var flow = superClass => class extends superClass {
8874
9049
  }
8875
9050
  }
8876
9051
 
8877
- return super.toAssignableList(exprList, trailingCommaPos, isLHS);
9052
+ return super.toAssignableList(exprList, trailingCommaLoc, isLHS);
8878
9053
  }
8879
9054
 
8880
9055
  toReferencedList(exprList, isParenthesizedExpr) {
@@ -8884,7 +9059,9 @@ var flow = superClass => class extends superClass {
8884
9059
  var expr = exprList[i];
8885
9060
 
8886
9061
  if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
8887
- this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern);
9062
+ this.raise(FlowErrors.TypeCastInPattern, {
9063
+ node: expr.typeAnnotation
9064
+ });
8888
9065
  }
8889
9066
  }
8890
9067
 
@@ -8941,7 +9118,7 @@ var flow = superClass => class extends superClass {
8941
9118
 
8942
9119
  pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
8943
9120
  if (method.variance) {
8944
- this.unexpected(method.variance.start);
9121
+ this.unexpected(method.variance.loc.start);
8945
9122
  }
8946
9123
 
8947
9124
  delete method.variance;
@@ -8956,20 +9133,24 @@ var flow = superClass => class extends superClass {
8956
9133
  var params = method.params;
8957
9134
 
8958
9135
  if (params.length > 0 && this.isThisParam(params[0])) {
8959
- this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
9136
+ this.raise(FlowErrors.ThisParamBannedInConstructor, {
9137
+ node: method
9138
+ });
8960
9139
  }
8961
9140
  } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
8962
9141
  var _params2 = method.value.params;
8963
9142
 
8964
9143
  if (_params2.length > 0 && this.isThisParam(_params2[0])) {
8965
- this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
9144
+ this.raise(FlowErrors.ThisParamBannedInConstructor, {
9145
+ node: method
9146
+ });
8966
9147
  }
8967
9148
  }
8968
9149
  }
8969
9150
 
8970
9151
  pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
8971
9152
  if (method.variance) {
8972
- this.unexpected(method.variance.start);
9153
+ this.unexpected(method.variance.loc.start);
8973
9154
  }
8974
9155
 
8975
9156
  delete method.variance;
@@ -9016,9 +9197,13 @@ var flow = superClass => class extends superClass {
9016
9197
  var param = params[0];
9017
9198
 
9018
9199
  if (this.isThisParam(param) && method.kind === "get") {
9019
- this.raise(param.start, FlowErrors.GetterMayNotHaveThisParam);
9200
+ this.raise(FlowErrors.GetterMayNotHaveThisParam, {
9201
+ node: param
9202
+ });
9020
9203
  } else if (this.isThisParam(param)) {
9021
- this.raise(param.start, FlowErrors.SetterMayNotHaveThisParam);
9204
+ this.raise(FlowErrors.SetterMayNotHaveThisParam, {
9205
+ node: param
9206
+ });
9022
9207
  }
9023
9208
  }
9024
9209
  }
@@ -9029,7 +9214,7 @@ var flow = superClass => class extends superClass {
9029
9214
 
9030
9215
  parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
9031
9216
  if (prop.variance) {
9032
- this.unexpected(prop.variance.start);
9217
+ this.unexpected(prop.variance.loc.start);
9033
9218
  }
9034
9219
 
9035
9220
  delete prop.variance;
@@ -9050,11 +9235,15 @@ var flow = superClass => class extends superClass {
9050
9235
  parseAssignableListItemTypes(param) {
9051
9236
  if (this.eat(17)) {
9052
9237
  if (param.type !== "Identifier") {
9053
- this.raise(param.start, FlowErrors.PatternIsOptional);
9238
+ this.raise(FlowErrors.PatternIsOptional, {
9239
+ node: param
9240
+ });
9054
9241
  }
9055
9242
 
9056
9243
  if (this.isThisParam(param)) {
9057
- this.raise(param.start, FlowErrors.ThisParamMayNotBeOptional);
9244
+ this.raise(FlowErrors.ThisParamMayNotBeOptional, {
9245
+ node: param
9246
+ });
9058
9247
  }
9059
9248
 
9060
9249
  param.optional = true;
@@ -9063,11 +9252,15 @@ var flow = superClass => class extends superClass {
9063
9252
  if (this.match(14)) {
9064
9253
  param.typeAnnotation = this.flowParseTypeAnnotation();
9065
9254
  } else if (this.isThisParam(param)) {
9066
- this.raise(param.start, FlowErrors.ThisParamAnnotationRequired);
9255
+ this.raise(FlowErrors.ThisParamAnnotationRequired, {
9256
+ node: param
9257
+ });
9067
9258
  }
9068
9259
 
9069
9260
  if (this.match(29) && this.isThisParam(param)) {
9070
- this.raise(param.start, FlowErrors.ThisParamNoDefault);
9261
+ this.raise(FlowErrors.ThisParamNoDefault, {
9262
+ node: param
9263
+ });
9071
9264
  }
9072
9265
 
9073
9266
  this.resetEndLocation(param);
@@ -9078,7 +9271,9 @@ var flow = superClass => class extends superClass {
9078
9271
  var node = super.parseMaybeDefault(startPos, startLoc, left);
9079
9272
 
9080
9273
  if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
9081
- this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer);
9274
+ this.raise(FlowErrors.TypeBeforeInitializer, {
9275
+ node: node.typeAnnotation
9276
+ });
9082
9277
  }
9083
9278
 
9084
9279
  return node;
@@ -9115,7 +9310,7 @@ var flow = superClass => class extends superClass {
9115
9310
  } = lh;
9116
9311
 
9117
9312
  if (kind === "type" && type === 51) {
9118
- this.unexpected(lh.start);
9313
+ this.unexpected(null, lh.type);
9119
9314
  }
9120
9315
 
9121
9316
  if (isMaybeDefaultImport(type) || type === 5 || type === 51) {
@@ -9159,7 +9354,9 @@ var flow = superClass => class extends superClass {
9159
9354
  specifier.importKind = specifierTypeKind;
9160
9355
  } else {
9161
9356
  if (importedIsString) {
9162
- throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, firstIdent.value);
9357
+ throw this.raise(ErrorMessages.ImportBindingIsString, {
9358
+ node: specifier
9359
+ }, firstIdent.value);
9163
9360
  }
9164
9361
 
9165
9362
  specifier.imported = firstIdent;
@@ -9177,15 +9374,17 @@ var flow = superClass => class extends superClass {
9177
9374
  var specifierIsTypeImport = hasTypeImportKind(specifier);
9178
9375
 
9179
9376
  if (isInTypeOnlyImport && specifierIsTypeImport) {
9180
- this.raise(specifier.start, FlowErrors.ImportTypeShorthandOnlyInPureImport);
9377
+ this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, {
9378
+ node: specifier
9379
+ });
9181
9380
  }
9182
9381
 
9183
9382
  if (isInTypeOnlyImport || specifierIsTypeImport) {
9184
- this.checkReservedType(specifier.local.name, specifier.local.start, true);
9383
+ this.checkReservedType(specifier.local.name, specifier.local.loc.start, true);
9185
9384
  }
9186
9385
 
9187
9386
  if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) {
9188
- this.checkReservedWord(specifier.local.name, specifier.start, true, true);
9387
+ this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true);
9189
9388
  }
9190
9389
 
9191
9390
  this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
@@ -9282,7 +9481,9 @@ var flow = superClass => class extends superClass {
9282
9481
  if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
9283
9482
  if (!arrow.error && !arrow.aborted) {
9284
9483
  if (arrow.node.async) {
9285
- this.raise(typeParameters.start, FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction);
9484
+ this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, {
9485
+ node: typeParameters
9486
+ });
9286
9487
  }
9287
9488
 
9288
9489
  return arrow.node;
@@ -9303,7 +9504,9 @@ var flow = superClass => class extends superClass {
9303
9504
 
9304
9505
  if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
9305
9506
  if (arrow.thrown) throw arrow.error;
9306
- throw this.raise(typeParameters.start, FlowErrors.UnexpectedTokenAfterTypeParameter);
9507
+ throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, {
9508
+ node: typeParameters
9509
+ });
9307
9510
  }
9308
9511
 
9309
9512
  return super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
@@ -9348,7 +9551,9 @@ var flow = superClass => class extends superClass {
9348
9551
 
9349
9552
  for (var i = 0; i < node.params.length; i++) {
9350
9553
  if (this.isThisParam(node.params[i]) && i > 0) {
9351
- this.raise(node.params[i].start, FlowErrors.ThisParamMustBeFirst);
9554
+ this.raise(FlowErrors.ThisParamMustBeFirst, {
9555
+ node: node.params[i]
9556
+ });
9352
9557
  }
9353
9558
  }
9354
9559
 
@@ -9473,7 +9678,9 @@ var flow = superClass => class extends superClass {
9473
9678
  var fileNode = super.parseTopLevel(file, program);
9474
9679
 
9475
9680
  if (this.state.hasFlowComment) {
9476
- this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment);
9681
+ this.raise(FlowErrors.UnterminatedFlowComment, {
9682
+ at: this.state.curPosition()
9683
+ });
9477
9684
  }
9478
9685
 
9479
9686
  return fileNode;
@@ -9482,7 +9689,9 @@ var flow = superClass => class extends superClass {
9482
9689
  skipBlockComment() {
9483
9690
  if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
9484
9691
  if (this.state.hasFlowComment) {
9485
- this.unexpected(null, FlowErrors.NestedFlowComment);
9692
+ throw this.raise(FlowErrors.NestedFlowComment, {
9693
+ at: this.state.startLoc
9694
+ });
9486
9695
  }
9487
9696
 
9488
9697
  this.hasFlowCommentCompletion();
@@ -9492,13 +9701,15 @@ var flow = superClass => class extends superClass {
9492
9701
  }
9493
9702
 
9494
9703
  if (this.state.hasFlowComment) {
9495
- var end = this.input.indexOf("*-/", this.state.pos += 2);
9704
+ var end = this.input.indexOf("*-/", this.state.pos + 2);
9496
9705
 
9497
9706
  if (end === -1) {
9498
- throw this.raise(this.state.pos - 2, ErrorMessages.UnterminatedComment);
9707
+ throw this.raise(ErrorMessages.UnterminatedComment, {
9708
+ at: this.state.curPosition()
9709
+ });
9499
9710
  }
9500
9711
 
9501
- this.state.pos = end + 3;
9712
+ this.state.pos = end + 2 + 3;
9502
9713
  return;
9503
9714
  }
9504
9715
 
@@ -9537,93 +9748,64 @@ var flow = superClass => class extends superClass {
9537
9748
  var end = this.input.indexOf("*/", this.state.pos);
9538
9749
 
9539
9750
  if (end === -1) {
9540
- throw this.raise(this.state.pos, ErrorMessages.UnterminatedComment);
9751
+ throw this.raise(ErrorMessages.UnterminatedComment, {
9752
+ at: this.state.curPosition()
9753
+ });
9541
9754
  }
9542
9755
  }
9543
9756
 
9544
- flowEnumErrorBooleanMemberNotInitialized(pos, _ref6) {
9545
- var {
9546
- enumName,
9547
- memberName
9548
- } = _ref6;
9549
- this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName);
9550
- }
9551
-
9552
- flowEnumErrorInvalidMemberName(pos, _ref7) {
9553
- var {
9554
- enumName,
9555
- memberName
9556
- } = _ref7;
9557
- var suggestion = memberName[0].toUpperCase() + memberName.slice(1);
9558
- this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName);
9559
- }
9560
-
9561
- flowEnumErrorDuplicateMemberName(pos, _ref8) {
9757
+ flowEnumErrorBooleanMemberNotInitialized(loc, _ref8) {
9562
9758
  var {
9563
9759
  enumName,
9564
9760
  memberName
9565
9761
  } = _ref8;
9566
- this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName);
9762
+ this.raise(FlowErrors.EnumBooleanMemberNotInitialized, {
9763
+ at: loc
9764
+ }, memberName, enumName);
9567
9765
  }
9568
9766
 
9569
- flowEnumErrorInconsistentMemberValues(pos, _ref9) {
9570
- var {
9571
- enumName
9572
- } = _ref9;
9573
- this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);
9574
- }
9575
-
9576
- flowEnumErrorInvalidExplicitType(pos, _ref10) {
9767
+ flowEnumErrorInvalidExplicitType(loc, _ref9) {
9577
9768
  var {
9578
9769
  enumName,
9579
9770
  suppliedType
9580
- } = _ref10;
9581
- return this.raise(pos, suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, enumName, suppliedType);
9771
+ } = _ref9;
9772
+ return this.raise(suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, {
9773
+ at: loc
9774
+ }, enumName, suppliedType);
9582
9775
  }
9583
9776
 
9584
- flowEnumErrorInvalidMemberInitializer(pos, _ref11) {
9777
+ flowEnumErrorInvalidMemberInitializer(loc, _ref10) {
9585
9778
  var {
9586
9779
  enumName,
9587
9780
  explicitType,
9588
9781
  memberName
9589
- } = _ref11;
9590
- var message = null;
9591
-
9592
- switch (explicitType) {
9593
- case "boolean":
9594
- case "number":
9595
- case "string":
9596
- message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;
9597
- break;
9598
-
9599
- case "symbol":
9600
- message = FlowErrors.EnumInvalidMemberInitializerSymbolType;
9601
- break;
9602
-
9603
- default:
9604
- message = FlowErrors.EnumInvalidMemberInitializerUnknownType;
9605
- }
9606
-
9607
- return this.raise(pos, message, enumName, memberName, explicitType);
9782
+ } = _ref10;
9783
+ return this.raise(explicitType === "boolean" || explicitType === "number" || explicitType === "string" ? FlowErrors.EnumInvalidMemberInitializerPrimaryType : explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerUnknownType, {
9784
+ at: loc
9785
+ }, enumName, memberName, explicitType);
9608
9786
  }
9609
9787
 
9610
- flowEnumErrorNumberMemberNotInitialized(pos, _ref12) {
9788
+ flowEnumErrorNumberMemberNotInitialized(loc, _ref11) {
9611
9789
  var {
9612
9790
  enumName,
9613
9791
  memberName
9614
- } = _ref12;
9615
- this.raise(pos, FlowErrors.EnumNumberMemberNotInitialized, enumName, memberName);
9792
+ } = _ref11;
9793
+ this.raise(FlowErrors.EnumNumberMemberNotInitialized, {
9794
+ at: loc
9795
+ }, enumName, memberName);
9616
9796
  }
9617
9797
 
9618
- flowEnumErrorStringMemberInconsistentlyInitailized(pos, _ref13) {
9798
+ flowEnumErrorStringMemberInconsistentlyInitailized(node, _ref12) {
9619
9799
  var {
9620
9800
  enumName
9621
- } = _ref13;
9622
- this.raise(pos, FlowErrors.EnumStringMemberInconsistentlyInitailized, enumName);
9801
+ } = _ref12;
9802
+ this.raise(FlowErrors.EnumStringMemberInconsistentlyInitailized, {
9803
+ node
9804
+ }, enumName);
9623
9805
  }
9624
9806
 
9625
9807
  flowEnumMemberInit() {
9626
- var startPos = this.state.start;
9808
+ var startLoc = this.state.startLoc;
9627
9809
 
9628
9810
  var endOfInit = () => this.match(12) || this.match(8);
9629
9811
 
@@ -9635,14 +9817,14 @@ var flow = superClass => class extends superClass {
9635
9817
  if (endOfInit()) {
9636
9818
  return {
9637
9819
  type: "number",
9638
- pos: literal.start,
9820
+ loc: literal.loc.start,
9639
9821
  value: literal
9640
9822
  };
9641
9823
  }
9642
9824
 
9643
9825
  return {
9644
9826
  type: "invalid",
9645
- pos: startPos
9827
+ loc: startLoc
9646
9828
  };
9647
9829
  }
9648
9830
 
@@ -9653,14 +9835,14 @@ var flow = superClass => class extends superClass {
9653
9835
  if (endOfInit()) {
9654
9836
  return {
9655
9837
  type: "string",
9656
- pos: _literal.start,
9838
+ loc: _literal.loc.start,
9657
9839
  value: _literal
9658
9840
  };
9659
9841
  }
9660
9842
 
9661
9843
  return {
9662
9844
  type: "invalid",
9663
- pos: startPos
9845
+ loc: startLoc
9664
9846
  };
9665
9847
  }
9666
9848
 
@@ -9672,31 +9854,31 @@ var flow = superClass => class extends superClass {
9672
9854
  if (endOfInit()) {
9673
9855
  return {
9674
9856
  type: "boolean",
9675
- pos: _literal2.start,
9857
+ loc: _literal2.loc.start,
9676
9858
  value: _literal2
9677
9859
  };
9678
9860
  }
9679
9861
 
9680
9862
  return {
9681
9863
  type: "invalid",
9682
- pos: startPos
9864
+ loc: startLoc
9683
9865
  };
9684
9866
  }
9685
9867
 
9686
9868
  default:
9687
9869
  return {
9688
9870
  type: "invalid",
9689
- pos: startPos
9871
+ loc: startLoc
9690
9872
  };
9691
9873
  }
9692
9874
  }
9693
9875
 
9694
9876
  flowEnumMemberRaw() {
9695
- var pos = this.state.start;
9877
+ var loc = this.state.startLoc;
9696
9878
  var id = this.parseIdentifier(true);
9697
9879
  var init = this.eat(29) ? this.flowEnumMemberInit() : {
9698
9880
  type: "none",
9699
- pos
9881
+ loc
9700
9882
  };
9701
9883
  return {
9702
9884
  id,
@@ -9704,7 +9886,7 @@ var flow = superClass => class extends superClass {
9704
9886
  };
9705
9887
  }
9706
9888
 
9707
- flowEnumCheckExplicitTypeMismatch(pos, context, expectedType) {
9889
+ flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) {
9708
9890
  var {
9709
9891
  explicitType
9710
9892
  } = context;
@@ -9714,15 +9896,15 @@ var flow = superClass => class extends superClass {
9714
9896
  }
9715
9897
 
9716
9898
  if (explicitType !== expectedType) {
9717
- this.flowEnumErrorInvalidMemberInitializer(pos, context);
9899
+ this.flowEnumErrorInvalidMemberInitializer(loc, context);
9718
9900
  }
9719
9901
  }
9720
9902
 
9721
- flowEnumMembers(_ref14) {
9903
+ flowEnumMembers(_ref13) {
9722
9904
  var {
9723
9905
  enumName,
9724
9906
  explicitType
9725
- } = _ref14;
9907
+ } = _ref13;
9726
9908
  var seenNames = new Set();
9727
9909
  var members = {
9728
9910
  booleanMembers: [],
@@ -9750,17 +9932,15 @@ var flow = superClass => class extends superClass {
9750
9932
  }
9751
9933
 
9752
9934
  if (/^[a-z]/.test(memberName)) {
9753
- this.flowEnumErrorInvalidMemberName(id.start, {
9754
- enumName,
9755
- memberName
9756
- });
9935
+ this.raise(FlowErrors.EnumInvalidMemberName, {
9936
+ node: id
9937
+ }, memberName, memberName[0].toUpperCase() + memberName.slice(1), enumName);
9757
9938
  }
9758
9939
 
9759
9940
  if (seenNames.has(memberName)) {
9760
- this.flowEnumErrorDuplicateMemberName(id.start, {
9761
- enumName,
9762
- memberName
9763
- });
9941
+ this.raise(FlowErrors.EnumDuplicateMemberName, {
9942
+ node: id
9943
+ }, memberName, enumName);
9764
9944
  }
9765
9945
 
9766
9946
  seenNames.add(memberName);
@@ -9774,7 +9954,7 @@ var flow = superClass => class extends superClass {
9774
9954
  switch (init.type) {
9775
9955
  case "boolean":
9776
9956
  {
9777
- this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "boolean");
9957
+ this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean");
9778
9958
  memberNode.init = init.value;
9779
9959
  members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
9780
9960
  break;
@@ -9782,7 +9962,7 @@ var flow = superClass => class extends superClass {
9782
9962
 
9783
9963
  case "number":
9784
9964
  {
9785
- this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number");
9965
+ this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number");
9786
9966
  memberNode.init = init.value;
9787
9967
  members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
9788
9968
  break;
@@ -9790,7 +9970,7 @@ var flow = superClass => class extends superClass {
9790
9970
 
9791
9971
  case "string":
9792
9972
  {
9793
- this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string");
9973
+ this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string");
9794
9974
  memberNode.init = init.value;
9795
9975
  members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
9796
9976
  break;
@@ -9798,18 +9978,18 @@ var flow = superClass => class extends superClass {
9798
9978
 
9799
9979
  case "invalid":
9800
9980
  {
9801
- throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context);
9981
+ throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context);
9802
9982
  }
9803
9983
 
9804
9984
  case "none":
9805
9985
  {
9806
9986
  switch (explicitType) {
9807
9987
  case "boolean":
9808
- this.flowEnumErrorBooleanMemberNotInitialized(init.pos, context);
9988
+ this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context);
9809
9989
  break;
9810
9990
 
9811
9991
  case "number":
9812
- this.flowEnumErrorNumberMemberNotInitialized(init.pos, context);
9992
+ this.flowEnumErrorNumberMemberNotInitialized(init.loc, context);
9813
9993
  break;
9814
9994
 
9815
9995
  default:
@@ -9829,10 +10009,10 @@ var flow = superClass => class extends superClass {
9829
10009
  };
9830
10010
  }
9831
10011
 
9832
- flowEnumStringMembers(initializedMembers, defaultedMembers, _ref15) {
10012
+ flowEnumStringMembers(initializedMembers, defaultedMembers, _ref14) {
9833
10013
  var {
9834
10014
  enumName
9835
- } = _ref15;
10015
+ } = _ref14;
9836
10016
 
9837
10017
  if (initializedMembers.length === 0) {
9838
10018
  return defaultedMembers;
@@ -9840,7 +10020,7 @@ var flow = superClass => class extends superClass {
9840
10020
  return initializedMembers;
9841
10021
  } else if (defaultedMembers.length > initializedMembers.length) {
9842
10022
  for (var member of initializedMembers) {
9843
- this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, {
10023
+ this.flowEnumErrorStringMemberInconsistentlyInitailized(member, {
9844
10024
  enumName
9845
10025
  });
9846
10026
  }
@@ -9848,7 +10028,7 @@ var flow = superClass => class extends superClass {
9848
10028
  return defaultedMembers;
9849
10029
  } else {
9850
10030
  for (var _member of defaultedMembers) {
9851
- this.flowEnumErrorStringMemberInconsistentlyInitailized(_member.start, {
10031
+ this.flowEnumErrorStringMemberInconsistentlyInitailized(_member, {
9852
10032
  enumName
9853
10033
  });
9854
10034
  }
@@ -9857,14 +10037,14 @@ var flow = superClass => class extends superClass {
9857
10037
  }
9858
10038
  }
9859
10039
 
9860
- flowEnumParseExplicitType(_ref16) {
10040
+ flowEnumParseExplicitType(_ref15) {
9861
10041
  var {
9862
10042
  enumName
9863
- } = _ref16;
10043
+ } = _ref15;
9864
10044
 
9865
10045
  if (this.eatContextual(97)) {
9866
10046
  if (!tokenIsIdentifier(this.state.type)) {
9867
- throw this.flowEnumErrorInvalidExplicitType(this.state.start, {
10047
+ throw this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
9868
10048
  enumName,
9869
10049
  suppliedType: null
9870
10050
  });
@@ -9876,7 +10056,7 @@ var flow = superClass => class extends superClass {
9876
10056
  this.next();
9877
10057
 
9878
10058
  if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
9879
- this.flowEnumErrorInvalidExplicitType(this.state.start, {
10059
+ this.flowEnumErrorInvalidExplicitType(this.state.startLoc, {
9880
10060
  enumName,
9881
10061
  suppliedType: value
9882
10062
  });
@@ -9888,11 +10068,9 @@ var flow = superClass => class extends superClass {
9888
10068
  return null;
9889
10069
  }
9890
10070
 
9891
- flowEnumBody(node, _ref17) {
9892
- var {
9893
- enumName,
9894
- nameLoc
9895
- } = _ref17;
10071
+ flowEnumBody(node, id) {
10072
+ var enumName = id.name;
10073
+ var nameLoc = id.loc.start;
9896
10074
  var explicitType = this.flowEnumParseExplicitType({
9897
10075
  enumName
9898
10076
  });
@@ -9956,7 +10134,7 @@ var flow = superClass => class extends superClass {
9956
10134
  return this.finishNode(node, "EnumStringBody");
9957
10135
  } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
9958
10136
  for (var member of members.defaultedMembers) {
9959
- this.flowEnumErrorBooleanMemberNotInitialized(member.start, {
10137
+ this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, {
9960
10138
  enumName,
9961
10139
  memberName: member.id.name
9962
10140
  });
@@ -9967,7 +10145,7 @@ var flow = superClass => class extends superClass {
9967
10145
  return this.finishNode(node, "EnumBooleanBody");
9968
10146
  } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
9969
10147
  for (var _member2 of members.defaultedMembers) {
9970
- this.flowEnumErrorNumberMemberNotInitialized(_member2.start, {
10148
+ this.flowEnumErrorNumberMemberNotInitialized(_member2.loc.start, {
9971
10149
  enumName,
9972
10150
  memberName: _member2.id.name
9973
10151
  });
@@ -9977,9 +10155,9 @@ var flow = superClass => class extends superClass {
9977
10155
  this.expect(8);
9978
10156
  return this.finishNode(node, "EnumNumberBody");
9979
10157
  } else {
9980
- this.flowEnumErrorInconsistentMemberValues(nameLoc, {
9981
- enumName
9982
- });
10158
+ this.raise(FlowErrors.EnumInconsistentMemberValues, {
10159
+ at: nameLoc
10160
+ }, enumName);
9983
10161
  return empty();
9984
10162
  }
9985
10163
  }
@@ -9989,10 +10167,7 @@ var flow = superClass => class extends superClass {
9989
10167
  flowParseEnumDeclaration(node) {
9990
10168
  var id = this.parseIdentifier();
9991
10169
  node.id = id;
9992
- node.body = this.flowEnumBody(this.startNode(), {
9993
- enumName: id.name,
9994
- nameLoc: id.start
9995
- });
10170
+ node.body = this.flowEnumBody(this.startNode(), id);
9996
10171
  return this.finishNode(node, "EnumDeclaration");
9997
10172
  }
9998
10173
 
@@ -10307,7 +10482,9 @@ var jsx = superClass => class extends superClass {
10307
10482
 
10308
10483
  for (;;) {
10309
10484
  if (this.state.pos >= this.length) {
10310
- throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);
10485
+ throw this.raise(JsxErrors.UnterminatedJsxContent, {
10486
+ at: this.state.startLoc
10487
+ });
10311
10488
  }
10312
10489
 
10313
10490
  var ch = this.input.charCodeAt(this.state.pos);
@@ -10371,7 +10548,9 @@ var jsx = superClass => class extends superClass {
10371
10548
 
10372
10549
  for (;;) {
10373
10550
  if (this.state.pos >= this.length) {
10374
- throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
10551
+ throw this.raise(ErrorMessages.UnterminatedString, {
10552
+ at: this.state.startLoc
10553
+ });
10375
10554
  }
10376
10555
 
10377
10556
  var ch = this.input.charCodeAt(this.state.pos);
@@ -10504,7 +10683,9 @@ var jsx = superClass => class extends superClass {
10504
10683
  node = this.jsxParseExpressionContainer(node, types.j_oTag);
10505
10684
 
10506
10685
  if (node.expression.type === "JSXEmptyExpression") {
10507
- this.raise(node.start, JsxErrors.AttributeIsEmpty);
10686
+ this.raise(JsxErrors.AttributeIsEmpty, {
10687
+ node
10688
+ });
10508
10689
  }
10509
10690
 
10510
10691
  return node;
@@ -10514,13 +10695,15 @@ var jsx = superClass => class extends superClass {
10514
10695
  return this.parseExprAtom();
10515
10696
 
10516
10697
  default:
10517
- throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);
10698
+ throw this.raise(JsxErrors.UnsupportedJsxValue, {
10699
+ at: this.state.startLoc
10700
+ });
10518
10701
  }
10519
10702
  }
10520
10703
 
10521
10704
  jsxParseEmptyExpression() {
10522
- var node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
10523
- return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
10705
+ var node = this.startNodeAt(indexes.get(this.state.lastTokEndLoc), this.state.lastTokEndLoc);
10706
+ return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc);
10524
10707
  }
10525
10708
 
10526
10709
  jsxParseSpreadChild(node) {
@@ -10647,13 +10830,19 @@ var jsx = superClass => class extends superClass {
10647
10830
  }
10648
10831
  }
10649
10832
 
10650
- if (isFragment(openingElement) && !isFragment(closingElement)) {
10651
- this.raise(closingElement.start, JsxErrors.MissingClosingTagFragment);
10833
+ if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) {
10834
+ this.raise(JsxErrors.MissingClosingTagFragment, {
10835
+ node: closingElement
10836
+ });
10652
10837
  } else if (!isFragment(openingElement) && isFragment(closingElement)) {
10653
- this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
10838
+ this.raise(JsxErrors.MissingClosingTagElement, {
10839
+ node: closingElement
10840
+ }, getQualifiedJSXName(openingElement.name));
10654
10841
  } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
10655
10842
  if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
10656
- this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
10843
+ this.raise(JsxErrors.MissingClosingTagElement, {
10844
+ node: closingElement
10845
+ }, getQualifiedJSXName(openingElement.name));
10657
10846
  }
10658
10847
  }
10659
10848
  }
@@ -10669,7 +10858,9 @@ var jsx = superClass => class extends superClass {
10669
10858
  node.children = children;
10670
10859
 
10671
10860
  if (this.match(45)) {
10672
- throw this.raise(this.state.start, JsxErrors.UnwrappedAdjacentJSXElements);
10861
+ throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, {
10862
+ at: this.state.startLoc
10863
+ });
10673
10864
  }
10674
10865
 
10675
10866
  return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
@@ -10782,7 +10973,7 @@ class TypeScriptScopeHandler extends ScopeHandler {
10782
10973
  return new TypeScriptScope(flags);
10783
10974
  }
10784
10975
 
10785
- declareName(name, bindingType, pos) {
10976
+ declareName(name, bindingType, loc) {
10786
10977
  var scope = this.currentScope();
10787
10978
 
10788
10979
  if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
@@ -10795,7 +10986,7 @@ class TypeScriptScopeHandler extends ScopeHandler {
10795
10986
 
10796
10987
  if (bindingType & BIND_KIND_TYPE) {
10797
10988
  if (!(bindingType & BIND_KIND_VALUE)) {
10798
- this.checkRedeclarationInScope(scope, name, bindingType, pos);
10989
+ this.checkRedeclarationInScope(scope, name, bindingType, loc);
10799
10990
  this.maybeExportDefined(scope, name);
10800
10991
  }
10801
10992
 
@@ -10996,49 +11187,61 @@ var typescript = superClass => class extends superClass {
10996
11187
  }
10997
11188
 
10998
11189
  tsParseModifiers(modified, allowedModifiers, disallowedModifiers, errorTemplate, stopOnStartOfClassStaticBlock) {
10999
- var enforceOrder = (pos, modifier, before, after) => {
11190
+ var enforceOrder = (loc, modifier, before, after) => {
11000
11191
  if (modifier === before && modified[after]) {
11001
- this.raise(pos, TSErrors.InvalidModifiersOrder, before, after);
11192
+ this.raise(TSErrors.InvalidModifiersOrder, {
11193
+ at: loc
11194
+ }, before, after);
11002
11195
  }
11003
11196
  };
11004
11197
 
11005
- var incompatible = (pos, modifier, mod1, mod2) => {
11198
+ var incompatible = (loc, modifier, mod1, mod2) => {
11006
11199
  if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) {
11007
- this.raise(pos, TSErrors.IncompatibleModifiers, mod1, mod2);
11200
+ this.raise(TSErrors.IncompatibleModifiers, {
11201
+ at: loc
11202
+ }, mod1, mod2);
11008
11203
  }
11009
11204
  };
11010
11205
 
11011
11206
  for (;;) {
11012
- var startPos = this.state.start;
11207
+ var {
11208
+ startLoc
11209
+ } = this.state;
11013
11210
  var modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock);
11014
11211
  if (!modifier) break;
11015
11212
 
11016
11213
  if (tsIsAccessModifier(modifier)) {
11017
11214
  if (modified.accessibility) {
11018
- this.raise(startPos, TSErrors.DuplicateAccessibilityModifier);
11215
+ this.raise(TSErrors.DuplicateAccessibilityModifier, {
11216
+ at: startLoc
11217
+ });
11019
11218
  } else {
11020
- enforceOrder(startPos, modifier, modifier, "override");
11021
- enforceOrder(startPos, modifier, modifier, "static");
11022
- enforceOrder(startPos, modifier, modifier, "readonly");
11219
+ enforceOrder(startLoc, modifier, modifier, "override");
11220
+ enforceOrder(startLoc, modifier, modifier, "static");
11221
+ enforceOrder(startLoc, modifier, modifier, "readonly");
11023
11222
  modified.accessibility = modifier;
11024
11223
  }
11025
11224
  } else {
11026
11225
  if (Object.hasOwnProperty.call(modified, modifier)) {
11027
- this.raise(startPos, TSErrors.DuplicateModifier, modifier);
11226
+ this.raise(TSErrors.DuplicateModifier, {
11227
+ at: startLoc
11228
+ }, modifier);
11028
11229
  } else {
11029
- enforceOrder(startPos, modifier, "static", "readonly");
11030
- enforceOrder(startPos, modifier, "static", "override");
11031
- enforceOrder(startPos, modifier, "override", "readonly");
11032
- enforceOrder(startPos, modifier, "abstract", "override");
11033
- incompatible(startPos, modifier, "declare", "override");
11034
- incompatible(startPos, modifier, "static", "abstract");
11230
+ enforceOrder(startLoc, modifier, "static", "readonly");
11231
+ enforceOrder(startLoc, modifier, "static", "override");
11232
+ enforceOrder(startLoc, modifier, "override", "readonly");
11233
+ enforceOrder(startLoc, modifier, "abstract", "override");
11234
+ incompatible(startLoc, modifier, "declare", "override");
11235
+ incompatible(startLoc, modifier, "static", "abstract");
11035
11236
  }
11036
11237
 
11037
11238
  modified[modifier] = true;
11038
11239
  }
11039
11240
 
11040
11241
  if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
11041
- this.raise(startPos, errorTemplate, modifier);
11242
+ this.raise(errorTemplate, {
11243
+ at: startLoc
11244
+ }, modifier);
11042
11245
  }
11043
11246
  }
11044
11247
  }
@@ -11143,7 +11346,9 @@ var typescript = superClass => class extends superClass {
11143
11346
  this.expect(10);
11144
11347
 
11145
11348
  if (!this.match(125)) {
11146
- this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument);
11349
+ this.raise(TSErrors.UnsupportedImportTypeArgument, {
11350
+ at: this.state.startLoc
11351
+ });
11147
11352
  }
11148
11353
 
11149
11354
  node.argument = this.parseExprAtom();
@@ -11241,7 +11446,9 @@ var typescript = superClass => class extends superClass {
11241
11446
  node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true, refTrailingCommaPos);
11242
11447
 
11243
11448
  if (node.params.length === 0) {
11244
- this.raise(node.start, TSErrors.EmptyTypeParameters);
11449
+ this.raise(TSErrors.EmptyTypeParameters, {
11450
+ node
11451
+ });
11245
11452
  }
11246
11453
 
11247
11454
  if (refTrailingCommaPos.value !== -1) {
@@ -11262,21 +11469,25 @@ var typescript = superClass => class extends superClass {
11262
11469
 
11263
11470
  tsFillSignature(returnToken, signature) {
11264
11471
  var returnTokenRequired = returnToken === 19;
11472
+ var paramsKey = "parameters";
11473
+ var returnTypeKey = "typeAnnotation";
11265
11474
  signature.typeParameters = this.tsTryParseTypeParameters();
11266
11475
  this.expect(10);
11267
- signature.parameters = this.tsParseBindingListForSignature();
11476
+ signature[paramsKey] = this.tsParseBindingListForSignature();
11268
11477
 
11269
11478
  if (returnTokenRequired) {
11270
- signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11479
+ signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11271
11480
  } else if (this.match(returnToken)) {
11272
- signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11481
+ signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
11273
11482
  }
11274
11483
  }
11275
11484
 
11276
11485
  tsParseBindingListForSignature() {
11277
11486
  return this.parseBindingList(11, 41).map(pattern => {
11278
11487
  if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
11279
- this.raise(pattern.start, TSErrors.UnsupportedSignatureParameterKind, pattern.type);
11488
+ this.raise(TSErrors.UnsupportedSignatureParameterKind, {
11489
+ node: pattern
11490
+ }, pattern.type);
11280
11491
  }
11281
11492
 
11282
11493
  return pattern;
@@ -11329,47 +11540,67 @@ var typescript = superClass => class extends superClass {
11329
11540
 
11330
11541
  if (this.match(10) || this.match(45)) {
11331
11542
  if (readonly) {
11332
- this.raise(node.start, TSErrors.ReadonlyForMethodSignature);
11543
+ this.raise(TSErrors.ReadonlyForMethodSignature, {
11544
+ node
11545
+ });
11333
11546
  }
11334
11547
 
11335
11548
  var method = nodeAny;
11336
11549
 
11337
11550
  if (method.kind && this.match(45)) {
11338
- this.raise(this.state.pos, TSErrors.AccesorCannotHaveTypeParameters);
11551
+ this.raise(TSErrors.AccesorCannotHaveTypeParameters, {
11552
+ at: this.state.curPosition()
11553
+ });
11339
11554
  }
11340
11555
 
11341
11556
  this.tsFillSignature(14, method);
11342
11557
  this.tsParseTypeMemberSemicolon();
11558
+ var paramsKey = "parameters";
11559
+ var returnTypeKey = "typeAnnotation";
11343
11560
 
11344
11561
  if (method.kind === "get") {
11345
- if (method.parameters.length > 0) {
11346
- this.raise(this.state.pos, ErrorMessages.BadGetterArity);
11562
+ if (method[paramsKey].length > 0) {
11563
+ this.raise(ErrorMessages.BadGetterArity, {
11564
+ at: this.state.curPosition()
11565
+ });
11347
11566
 
11348
- if (this.isThisParam(method.parameters[0])) {
11349
- this.raise(this.state.pos, TSErrors.AccesorCannotDeclareThisParameter);
11567
+ if (this.isThisParam(method[paramsKey][0])) {
11568
+ this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
11569
+ at: this.state.curPosition()
11570
+ });
11350
11571
  }
11351
11572
  }
11352
11573
  } else if (method.kind === "set") {
11353
- if (method.parameters.length !== 1) {
11354
- this.raise(this.state.pos, ErrorMessages.BadSetterArity);
11574
+ if (method[paramsKey].length !== 1) {
11575
+ this.raise(ErrorMessages.BadSetterArity, {
11576
+ at: this.state.curPosition()
11577
+ });
11355
11578
  } else {
11356
- var firstParameter = method.parameters[0];
11579
+ var firstParameter = method[paramsKey][0];
11357
11580
 
11358
11581
  if (this.isThisParam(firstParameter)) {
11359
- this.raise(this.state.pos, TSErrors.AccesorCannotDeclareThisParameter);
11582
+ this.raise(TSErrors.AccesorCannotDeclareThisParameter, {
11583
+ at: this.state.curPosition()
11584
+ });
11360
11585
  }
11361
11586
 
11362
11587
  if (firstParameter.type === "Identifier" && firstParameter.optional) {
11363
- this.raise(this.state.pos, TSErrors.SetAccesorCannotHaveOptionalParameter);
11588
+ this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, {
11589
+ at: this.state.curPosition()
11590
+ });
11364
11591
  }
11365
11592
 
11366
11593
  if (firstParameter.type === "RestElement") {
11367
- this.raise(this.state.pos, TSErrors.SetAccesorCannotHaveRestParameter);
11594
+ this.raise(TSErrors.SetAccesorCannotHaveRestParameter, {
11595
+ at: this.state.curPosition()
11596
+ });
11368
11597
  }
11369
11598
  }
11370
11599
 
11371
- if (method.typeAnnotation) {
11372
- this.raise(method.typeAnnotation.start, TSErrors.SetAccesorCannotHaveReturnType);
11600
+ if (method[returnTypeKey]) {
11601
+ this.raise(TSErrors.SetAccesorCannotHaveReturnType, {
11602
+ node: method[returnTypeKey]
11603
+ });
11373
11604
  }
11374
11605
  } else {
11375
11606
  method.kind = "method";
@@ -11511,7 +11742,9 @@ var typescript = superClass => class extends superClass {
11511
11742
  } = elementNode;
11512
11743
 
11513
11744
  if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
11514
- this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired);
11745
+ this.raise(TSErrors.OptionalTypeBeforeRequired, {
11746
+ node: elementNode
11747
+ });
11515
11748
  }
11516
11749
 
11517
11750
  seenOptionalElement = seenOptionalElement || type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType";
@@ -11525,7 +11758,9 @@ var typescript = superClass => class extends superClass {
11525
11758
  labeledElements = (_labeledElements = labeledElements) != null ? _labeledElements : isLabeled;
11526
11759
 
11527
11760
  if (labeledElements !== isLabeled) {
11528
- this.raise(elementNode.start, TSErrors.MixedLabeledAndUnlabeledElements);
11761
+ this.raise(TSErrors.MixedLabeledAndUnlabeledElements, {
11762
+ node: elementNode
11763
+ });
11529
11764
  }
11530
11765
  });
11531
11766
  return this.finishNode(node, "TSTupleType");
@@ -11548,7 +11783,9 @@ var typescript = superClass => class extends superClass {
11548
11783
  if (type.type === "TSTypeReference" && !type.typeParameters && type.typeName.type === "Identifier") {
11549
11784
  labeledNode.label = type.typeName;
11550
11785
  } else {
11551
- this.raise(type.start, TSErrors.InvalidTupleMemberLabel);
11786
+ this.raise(TSErrors.InvalidTupleMemberLabel, {
11787
+ node: type
11788
+ });
11552
11789
  labeledNode.label = type;
11553
11790
  }
11554
11791
 
@@ -11744,7 +11981,9 @@ var typescript = superClass => class extends superClass {
11744
11981
  return;
11745
11982
 
11746
11983
  default:
11747
- this.raise(node.start, TSErrors.UnexpectedReadonly);
11984
+ this.raise(TSErrors.UnexpectedReadonly, {
11985
+ node
11986
+ });
11748
11987
  }
11749
11988
  }
11750
11989
 
@@ -11943,7 +12182,9 @@ var typescript = superClass => class extends superClass {
11943
12182
  }
11944
12183
 
11945
12184
  if (containsEsc) {
11946
- this.raise(this.state.lastTokStart, ErrorMessages.InvalidEscapedReservedWord, "asserts");
12185
+ this.raise(ErrorMessages.InvalidEscapedReservedWord, {
12186
+ at: this.state.lastTokStartLoc
12187
+ }, "asserts");
11947
12188
  }
11948
12189
 
11949
12190
  return true;
@@ -11997,7 +12238,9 @@ var typescript = superClass => class extends superClass {
11997
12238
 
11998
12239
  tsParseTypeAssertion() {
11999
12240
  if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
12000
- this.raise(this.state.start, TSErrors.ReservedTypeAssertion);
12241
+ this.raise(TSErrors.ReservedTypeAssertion, {
12242
+ at: this.state.startLoc
12243
+ });
12001
12244
  }
12002
12245
 
12003
12246
  var node = this.startNode();
@@ -12011,11 +12254,13 @@ var typescript = superClass => class extends superClass {
12011
12254
  }
12012
12255
 
12013
12256
  tsParseHeritageClause(descriptor) {
12014
- var originalStart = this.state.start;
12257
+ var originalStartLoc = this.state.startLoc;
12015
12258
  var delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
12016
12259
 
12017
12260
  if (!delimitedList.length) {
12018
- this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor);
12261
+ this.raise(TSErrors.EmptyHeritageClauseType, {
12262
+ at: originalStartLoc
12263
+ }, descriptor);
12019
12264
  }
12020
12265
 
12021
12266
  return delimitedList;
@@ -12038,7 +12283,9 @@ var typescript = superClass => class extends superClass {
12038
12283
  this.checkLVal(node.id, "typescript interface declaration", BIND_TS_INTERFACE);
12039
12284
  } else {
12040
12285
  node.id = null;
12041
- this.raise(this.state.start, TSErrors.MissingInterfaceName);
12286
+ this.raise(TSErrors.MissingInterfaceName, {
12287
+ at: this.state.startLoc
12288
+ });
12042
12289
  }
12043
12290
 
12044
12291
  node.typeParameters = this.tsTryParseTypeParameters();
@@ -12198,7 +12445,9 @@ var typescript = superClass => class extends superClass {
12198
12445
  var moduleReference = this.tsParseModuleReference();
12199
12446
 
12200
12447
  if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") {
12201
- this.raise(moduleReference.start, TSErrors.ImportAliasHasImportType);
12448
+ this.raise(TSErrors.ImportAliasHasImportType, {
12449
+ node: moduleReference
12450
+ });
12202
12451
  }
12203
12452
 
12204
12453
  node.moduleReference = moduleReference;
@@ -12432,7 +12681,9 @@ var typescript = superClass => class extends superClass {
12432
12681
  }));
12433
12682
 
12434
12683
  if (node.params.length === 0) {
12435
- this.raise(node.start, TSErrors.EmptyTypeArguments);
12684
+ this.raise(TSErrors.EmptyTypeArguments, {
12685
+ node
12686
+ });
12436
12687
  }
12437
12688
 
12438
12689
  this.expect(46);
@@ -12463,7 +12714,9 @@ var typescript = superClass => class extends superClass {
12463
12714
  readonly = modified.readonly;
12464
12715
 
12465
12716
  if (allowModifiers === false && (accessibility || readonly || override)) {
12466
- this.raise(startPos, TSErrors.UnexpectedParameterModifier);
12717
+ this.raise(TSErrors.UnexpectedParameterModifier, {
12718
+ at: startLoc
12719
+ });
12467
12720
  }
12468
12721
  }
12469
12722
 
@@ -12483,7 +12736,9 @@ var typescript = superClass => class extends superClass {
12483
12736
  if (override) pp.override = override;
12484
12737
 
12485
12738
  if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
12486
- this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind);
12739
+ this.raise(TSErrors.UnsupportedParameterPropertyKind, {
12740
+ node: pp
12741
+ });
12487
12742
  }
12488
12743
 
12489
12744
  pp.parameter = elt;
@@ -12512,7 +12767,9 @@ var typescript = superClass => class extends superClass {
12512
12767
  }
12513
12768
 
12514
12769
  if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) {
12515
- this.raise(node.start, TSErrors.DeclareFunctionHasImplementation);
12770
+ this.raise(TSErrors.DeclareFunctionHasImplementation, {
12771
+ node
12772
+ });
12516
12773
 
12517
12774
  if (node.declare) {
12518
12775
  super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
@@ -12534,7 +12791,9 @@ var typescript = superClass => class extends superClass {
12534
12791
  tsCheckForInvalidTypeCasts(items) {
12535
12792
  items.forEach(node => {
12536
12793
  if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
12537
- this.raise(node.typeAnnotation.start, TSErrors.UnexpectedTypeAnnotation);
12794
+ this.raise(TSErrors.UnexpectedTypeAnnotation, {
12795
+ node: node.typeAnnotation
12796
+ });
12538
12797
  }
12539
12798
  });
12540
12799
  }
@@ -12576,7 +12835,7 @@ var typescript = superClass => class extends superClass {
12576
12835
  }
12577
12836
 
12578
12837
  if (this.match(45)) {
12579
- var missingParenErrorPos;
12838
+ var missingParenErrorLoc;
12580
12839
  var result = this.tsTryParseAndCatch(() => {
12581
12840
  if (!noCalls && this.atPossibleAsyncArrow(base)) {
12582
12841
  var asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
@@ -12592,7 +12851,7 @@ var typescript = superClass => class extends superClass {
12592
12851
 
12593
12852
  if (typeArguments) {
12594
12853
  if (isOptionalCall && !this.match(10)) {
12595
- missingParenErrorPos = this.state.pos;
12854
+ missingParenErrorLoc = this.state.curPosition();
12596
12855
  this.unexpected();
12597
12856
  }
12598
12857
 
@@ -12617,8 +12876,8 @@ var typescript = superClass => class extends superClass {
12617
12876
  this.unexpected();
12618
12877
  });
12619
12878
 
12620
- if (missingParenErrorPos) {
12621
- this.unexpected(missingParenErrorPos, 10);
12879
+ if (missingParenErrorLoc) {
12880
+ this.unexpected(missingParenErrorLoc, 10);
12622
12881
  }
12623
12882
 
12624
12883
  if (result) return result;
@@ -12688,7 +12947,9 @@ var typescript = superClass => class extends superClass {
12688
12947
  var importNode = super.parseImport(node);
12689
12948
 
12690
12949
  if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
12691
- this.raise(importNode.start, TSErrors.TypeImportCannotSpecifyDefaultAndNamed);
12950
+ this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, {
12951
+ node: importNode
12952
+ });
12692
12953
  }
12693
12954
 
12694
12955
  return importNode;
@@ -12795,7 +13056,9 @@ var typescript = superClass => class extends superClass {
12795
13056
  this.next();
12796
13057
 
12797
13058
  if (this.tsHasSomeModifiers(member, modifiers)) {
12798
- this.raise(this.state.pos, TSErrors.StaticBlockCannotHaveModifier);
13059
+ this.raise(TSErrors.StaticBlockCannotHaveModifier, {
13060
+ at: this.state.curPosition()
13061
+ });
12799
13062
  }
12800
13063
 
12801
13064
  this.parseClassStaticBlock(classBody, member);
@@ -12818,31 +13081,43 @@ var typescript = superClass => class extends superClass {
12818
13081
  classBody.body.push(idx);
12819
13082
 
12820
13083
  if (member.abstract) {
12821
- this.raise(member.start, TSErrors.IndexSignatureHasAbstract);
13084
+ this.raise(TSErrors.IndexSignatureHasAbstract, {
13085
+ node: member
13086
+ });
12822
13087
  }
12823
13088
 
12824
13089
  if (member.accessibility) {
12825
- this.raise(member.start, TSErrors.IndexSignatureHasAccessibility, member.accessibility);
13090
+ this.raise(TSErrors.IndexSignatureHasAccessibility, {
13091
+ node: member
13092
+ }, member.accessibility);
12826
13093
  }
12827
13094
 
12828
13095
  if (member.declare) {
12829
- this.raise(member.start, TSErrors.IndexSignatureHasDeclare);
13096
+ this.raise(TSErrors.IndexSignatureHasDeclare, {
13097
+ node: member
13098
+ });
12830
13099
  }
12831
13100
 
12832
13101
  if (member.override) {
12833
- this.raise(member.start, TSErrors.IndexSignatureHasOverride);
13102
+ this.raise(TSErrors.IndexSignatureHasOverride, {
13103
+ node: member
13104
+ });
12834
13105
  }
12835
13106
 
12836
13107
  return;
12837
13108
  }
12838
13109
 
12839
13110
  if (!this.state.inAbstractClass && member.abstract) {
12840
- this.raise(member.start, TSErrors.NonAbstractClassHasAbstractMethod);
13111
+ this.raise(TSErrors.NonAbstractClassHasAbstractMethod, {
13112
+ node: member
13113
+ });
12841
13114
  }
12842
13115
 
12843
13116
  if (member.override) {
12844
13117
  if (!state.hadSuperClass) {
12845
- this.raise(member.start, TSErrors.OverrideNotInSubClass);
13118
+ this.raise(TSErrors.OverrideNotInSubClass, {
13119
+ node: member
13120
+ });
12846
13121
  }
12847
13122
  }
12848
13123
 
@@ -12854,11 +13129,15 @@ var typescript = superClass => class extends superClass {
12854
13129
  if (optional) methodOrProp.optional = true;
12855
13130
 
12856
13131
  if (methodOrProp.readonly && this.match(10)) {
12857
- this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly);
13132
+ this.raise(TSErrors.ClassMethodHasReadonly, {
13133
+ node: methodOrProp
13134
+ });
12858
13135
  }
12859
13136
 
12860
13137
  if (methodOrProp.declare && this.match(10)) {
12861
- this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare);
13138
+ this.raise(TSErrors.ClassMethodHasDeclare, {
13139
+ node: methodOrProp
13140
+ });
12862
13141
  }
12863
13142
  }
12864
13143
 
@@ -12915,7 +13194,9 @@ var typescript = superClass => class extends superClass {
12915
13194
  var isDeclare = this.eatContextual(117);
12916
13195
 
12917
13196
  if (isDeclare && (this.isContextual(117) || !this.shouldParseExportDeclaration())) {
12918
- throw this.raise(this.state.start, TSErrors.ExpectedAmbientAfterExportDeclare);
13197
+ throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, {
13198
+ at: this.state.startLoc
13199
+ });
12919
13200
  }
12920
13201
 
12921
13202
  var declaration;
@@ -12963,14 +13244,18 @@ var typescript = superClass => class extends superClass {
12963
13244
  this.parseClassPropertyAnnotation(node);
12964
13245
 
12965
13246
  if (this.state.isAmbientContext && this.match(29)) {
12966
- this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);
13247
+ this.raise(TSErrors.DeclareClassFieldHasInitializer, {
13248
+ at: this.state.startLoc
13249
+ });
12967
13250
  }
12968
13251
 
12969
13252
  if (node.abstract && this.match(29)) {
12970
13253
  var {
12971
13254
  key
12972
13255
  } = node;
12973
- this.raise(this.state.start, TSErrors.AbstractPropertyHasInitializer, key.type === "Identifier" && !node.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
13256
+ this.raise(TSErrors.AbstractPropertyHasInitializer, {
13257
+ at: this.state.startLoc
13258
+ }, key.type === "Identifier" && !node.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
12974
13259
  }
12975
13260
 
12976
13261
  return super.parseClassProperty(node);
@@ -12978,11 +13263,15 @@ var typescript = superClass => class extends superClass {
12978
13263
 
12979
13264
  parseClassPrivateProperty(node) {
12980
13265
  if (node.abstract) {
12981
- this.raise(node.start, TSErrors.PrivateElementHasAbstract);
13266
+ this.raise(TSErrors.PrivateElementHasAbstract, {
13267
+ node
13268
+ });
12982
13269
  }
12983
13270
 
12984
13271
  if (node.accessibility) {
12985
- this.raise(node.start, TSErrors.PrivateElementHasAccessibility, node.accessibility);
13272
+ this.raise(TSErrors.PrivateElementHasAccessibility, {
13273
+ node
13274
+ }, node.accessibility);
12986
13275
  }
12987
13276
 
12988
13277
  this.parseClassPropertyAnnotation(node);
@@ -12993,11 +13282,15 @@ var typescript = superClass => class extends superClass {
12993
13282
  var typeParameters = this.tsTryParseTypeParameters();
12994
13283
 
12995
13284
  if (typeParameters && isConstructor) {
12996
- this.raise(typeParameters.start, TSErrors.ConstructorHasTypeParameters);
13285
+ this.raise(TSErrors.ConstructorHasTypeParameters, {
13286
+ node: typeParameters
13287
+ });
12997
13288
  }
12998
13289
 
12999
13290
  if (method.declare && (method.kind === "get" || method.kind === "set")) {
13000
- this.raise(method.start, TSErrors.DeclareAccessor, method.kind);
13291
+ this.raise(TSErrors.DeclareAccessor, {
13292
+ node: method
13293
+ }, method.kind);
13001
13294
  }
13002
13295
 
13003
13296
  if (typeParameters) method.typeParameters = typeParameters;
@@ -13048,7 +13341,7 @@ var typescript = superClass => class extends superClass {
13048
13341
  parseVarId(decl, kind) {
13049
13342
  super.parseVarId(decl, kind);
13050
13343
 
13051
- if (decl.id.type === "Identifier" && this.eat(35)) {
13344
+ if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) {
13052
13345
  decl.definite = true;
13053
13346
  }
13054
13347
 
@@ -13154,7 +13447,9 @@ var typescript = superClass => class extends superClass {
13154
13447
  var _node$extra;
13155
13448
 
13156
13449
  if (node.params.length === 1 && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
13157
- this.raise(node.start, TSErrors.ReservedArrowTypeParam);
13450
+ this.raise(TSErrors.ReservedArrowTypeParam, {
13451
+ node
13452
+ });
13158
13453
  }
13159
13454
  }
13160
13455
 
@@ -13187,7 +13482,9 @@ var typescript = superClass => class extends superClass {
13187
13482
  parseAssignableListItemTypes(param) {
13188
13483
  if (this.eat(17)) {
13189
13484
  if (param.type !== "Identifier" && !this.state.isAmbientContext && !this.state.inType) {
13190
- this.raise(param.start, TSErrors.PatternIsOptional);
13485
+ this.raise(TSErrors.PatternIsOptional, {
13486
+ node: param
13487
+ });
13191
13488
  }
13192
13489
 
13193
13490
  param.optional = true;
@@ -13268,7 +13565,9 @@ var typescript = superClass => class extends superClass {
13268
13565
  case "TSAsExpression":
13269
13566
  case "TSTypeAssertion":
13270
13567
  if (!args[0] && contextDescription !== "parenthesized expression" && !((_expr$extra2 = expr.extra) != null && _expr$extra2.parenthesized)) {
13271
- this.raise(expr.start, ErrorMessages.InvalidLhs, contextDescription);
13568
+ this.raise(ErrorMessages.InvalidLhs, {
13569
+ node: expr
13570
+ }, contextDescription);
13272
13571
  break;
13273
13572
  }
13274
13573
 
@@ -13305,7 +13604,7 @@ var typescript = superClass => class extends superClass {
13305
13604
  return call;
13306
13605
  }
13307
13606
 
13308
- this.unexpected(this.state.start, 10);
13607
+ this.unexpected(null, 10);
13309
13608
  }
13310
13609
 
13311
13610
  return super.parseMaybeDecoratorArguments(expr);
@@ -13314,8 +13613,9 @@ var typescript = superClass => class extends superClass {
13314
13613
  checkCommaAfterRest(close) {
13315
13614
  if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) {
13316
13615
  this.next();
13616
+ return false;
13317
13617
  } else {
13318
- super.checkCommaAfterRest(close);
13618
+ return super.checkCommaAfterRest(close);
13319
13619
  }
13320
13620
  }
13321
13621
 
@@ -13331,7 +13631,9 @@ var typescript = superClass => class extends superClass {
13331
13631
  var node = super.parseMaybeDefault(...arguments);
13332
13632
 
13333
13633
  if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
13334
- this.raise(node.typeAnnotation.start, TSErrors.TypeAnnotationAfterAssign);
13634
+ this.raise(TSErrors.TypeAnnotationAfterAssign, {
13635
+ node: node.typeAnnotation
13636
+ });
13335
13637
  }
13336
13638
 
13337
13639
  return node;
@@ -13380,7 +13682,9 @@ var typescript = superClass => class extends superClass {
13380
13682
  if (!this.state.maybeInArrowParameters) {
13381
13683
  exprList[i] = this.typeCastToParameter(expr);
13382
13684
  } else {
13383
- this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter);
13685
+ this.raise(TSErrors.UnexpectedTypeCastInParameter, {
13686
+ node: expr
13687
+ });
13384
13688
  }
13385
13689
 
13386
13690
  break;
@@ -13392,7 +13696,7 @@ var typescript = superClass => class extends superClass {
13392
13696
 
13393
13697
  typeCastToParameter(node) {
13394
13698
  node.expression.typeAnnotation = node.typeAnnotation;
13395
- this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
13699
+ this.resetEndLocation(node.expression, node.typeAnnotation.loc.end);
13396
13700
  return node.expression;
13397
13701
  }
13398
13702
 
@@ -13474,7 +13778,9 @@ var typescript = superClass => class extends superClass {
13474
13778
  } else if (this.isContextual(121)) {
13475
13779
  if (!this.hasFollowingLineBreak()) {
13476
13780
  node.abstract = true;
13477
- this.raise(node.start, TSErrors.NonClassMethodPropertyHasAbstractModifer);
13781
+ this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, {
13782
+ node
13783
+ });
13478
13784
  this.next();
13479
13785
  return this.tsParseInterfaceDeclaration(node);
13480
13786
  }
@@ -13493,7 +13799,9 @@ var typescript = superClass => class extends superClass {
13493
13799
  var {
13494
13800
  key
13495
13801
  } = method;
13496
- this.raise(method.start, TSErrors.AbstractMethodHasImplementation, key.type === "Identifier" && !method.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
13802
+ this.raise(TSErrors.AbstractMethodHasImplementation, {
13803
+ node: method
13804
+ }, key.type === "Identifier" && !method.computed ? key.name : "[".concat(this.input.slice(key.start, key.end), "]"));
13497
13805
  }
13498
13806
  }
13499
13807
 
@@ -13552,7 +13860,7 @@ var typescript = superClass => class extends superClass {
13552
13860
  var rightOfAs;
13553
13861
  var hasTypeSpecifier = false;
13554
13862
  var canParseAsKeyword = true;
13555
- var pos = leftOfAs.start;
13863
+ var loc = leftOfAs.loc.start;
13556
13864
 
13557
13865
  if (this.isContextual(89)) {
13558
13866
  var firstAs = this.parseIdentifier();
@@ -13582,7 +13890,9 @@ var typescript = superClass => class extends superClass {
13582
13890
  }
13583
13891
 
13584
13892
  if (hasTypeSpecifier && isInTypeOnlyImportExport) {
13585
- this.raise(pos, isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports);
13893
+ this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, {
13894
+ at: loc
13895
+ });
13586
13896
  }
13587
13897
 
13588
13898
  node[leftOfAsKey] = leftOfAs;
@@ -13605,9 +13915,9 @@ var typescript = superClass => class extends superClass {
13605
13915
 
13606
13916
  };
13607
13917
 
13608
- var PlaceHolderErrors = makeErrorTemplates({
13918
+ var PlaceholderErrors = makeErrorTemplates({
13609
13919
  ClassNameIsRequired: "A class name is required."
13610
- }, ErrorCodes.SyntaxError);
13920
+ }, ErrorCodes.SyntaxError, "placeholders");
13611
13921
 
13612
13922
  var placeholders = superClass => class extends superClass {
13613
13923
  parsePlaceholder(expectedNode) {
@@ -13730,7 +14040,9 @@ var placeholders = superClass => class extends superClass {
13730
14040
  node.body = this.finishPlaceholder(placeholder, "ClassBody");
13731
14041
  return this.finishNode(node, type);
13732
14042
  } else {
13733
- this.unexpected(null, PlaceHolderErrors.ClassNameIsRequired);
14043
+ throw this.raise(PlaceholderErrors.ClassNameIsRequired, {
14044
+ at: this.state.startLoc
14045
+ });
13734
14046
  }
13735
14047
  } else {
13736
14048
  this.parseClassId(node, isStatement, optionalId);
@@ -13830,7 +14142,7 @@ var placeholders = superClass => class extends superClass {
13830
14142
  var v8intrinsic = superClass => class extends superClass {
13831
14143
  parseV8Intrinsic() {
13832
14144
  if (this.match(50)) {
13833
- var v8IntrinsicStart = this.state.start;
14145
+ var v8IntrinsicStartLoc = this.state.startLoc;
13834
14146
  var node = this.startNode();
13835
14147
  this.next();
13836
14148
 
@@ -13844,7 +14156,7 @@ var v8intrinsic = superClass => class extends superClass {
13844
14156
  }
13845
14157
  }
13846
14158
 
13847
- this.unexpected(v8IntrinsicStart);
14159
+ this.unexpected(v8IntrinsicStartLoc);
13848
14160
  }
13849
14161
  }
13850
14162
 
@@ -14038,12 +14350,16 @@ class LValParser extends NodeUtils {
14038
14350
 
14039
14351
  if (isLHS) {
14040
14352
  if (parenthesized.type === "Identifier") {
14041
- this.expressionScope.recordParenthesizedIdentifierError(node.start, ErrorMessages.InvalidParenthesizedAssignment);
14353
+ this.expressionScope.recordParenthesizedIdentifierError(ErrorMessages.InvalidParenthesizedAssignment, node.loc.start);
14042
14354
  } else if (parenthesized.type !== "MemberExpression") {
14043
- this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
14355
+ this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
14356
+ node
14357
+ });
14044
14358
  }
14045
14359
  } else {
14046
- this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
14360
+ this.raise(ErrorMessages.InvalidParenthesizedAssignment, {
14361
+ node
14362
+ });
14047
14363
  }
14048
14364
  }
14049
14365
 
@@ -14065,8 +14381,10 @@ class LValParser extends NodeUtils {
14065
14381
  var isLast = i === last;
14066
14382
  this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
14067
14383
 
14068
- if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingComma) {
14069
- this.raiseRestNotLast(node.extra.trailingComma);
14384
+ if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) {
14385
+ this.raise(ErrorMessages.RestTrailingComma, {
14386
+ at: node.extra.trailingCommaLoc
14387
+ });
14070
14388
  }
14071
14389
  }
14072
14390
 
@@ -14087,12 +14405,14 @@ class LValParser extends NodeUtils {
14087
14405
 
14088
14406
  case "ArrayExpression":
14089
14407
  node.type = "ArrayPattern";
14090
- this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma, isLHS);
14408
+ this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS);
14091
14409
  break;
14092
14410
 
14093
14411
  case "AssignmentExpression":
14094
14412
  if (node.operator !== "=") {
14095
- this.raise(node.left.end, ErrorMessages.MissingEqInAssignment);
14413
+ this.raise(ErrorMessages.MissingEqInAssignment, {
14414
+ at: node.left.loc.end
14415
+ });
14096
14416
  }
14097
14417
 
14098
14418
  node.type = "AssignmentPattern";
@@ -14110,16 +14430,19 @@ class LValParser extends NodeUtils {
14110
14430
 
14111
14431
  toAssignableObjectExpressionProp(prop, isLast, isLHS) {
14112
14432
  if (prop.type === "ObjectMethod") {
14113
- var error = prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod;
14114
- this.raise(prop.key.start, error);
14433
+ this.raise(prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod, {
14434
+ node: prop.key
14435
+ });
14115
14436
  } else if (prop.type === "SpreadElement" && !isLast) {
14116
- this.raiseRestNotLast(prop.start);
14437
+ this.raise(ErrorMessages.RestTrailingComma, {
14438
+ node: prop
14439
+ });
14117
14440
  } else {
14118
14441
  this.toAssignable(prop, isLHS);
14119
14442
  }
14120
14443
  }
14121
14444
 
14122
- toAssignableList(exprList, trailingCommaPos, isLHS) {
14445
+ toAssignableList(exprList, trailingCommaLoc, isLHS) {
14123
14446
  var end = exprList.length;
14124
14447
 
14125
14448
  if (end) {
@@ -14137,8 +14460,10 @@ class LValParser extends NodeUtils {
14137
14460
  this.unexpected(arg.start);
14138
14461
  }
14139
14462
 
14140
- if (trailingCommaPos) {
14141
- this.raiseTrailingCommaAfterRest(trailingCommaPos);
14463
+ if (trailingCommaLoc) {
14464
+ this.raise(ErrorMessages.RestTrailingComma, {
14465
+ at: trailingCommaLoc
14466
+ });
14142
14467
  }
14143
14468
 
14144
14469
  --end;
@@ -14152,7 +14477,9 @@ class LValParser extends NodeUtils {
14152
14477
  this.toAssignable(elt, isLHS);
14153
14478
 
14154
14479
  if (elt.type === "RestElement") {
14155
- this.raiseRestNotLast(elt.start);
14480
+ this.raise(ErrorMessages.RestTrailingComma, {
14481
+ node: elt
14482
+ });
14156
14483
  }
14157
14484
  }
14158
14485
  }
@@ -14263,14 +14590,18 @@ class LValParser extends NodeUtils {
14263
14590
  break;
14264
14591
  } else if (this.match(21)) {
14265
14592
  elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
14266
- this.checkCommaAfterRest(closeCharCode);
14267
- this.expect(close);
14268
- break;
14593
+
14594
+ if (!this.checkCommaAfterRest(closeCharCode)) {
14595
+ this.expect(close);
14596
+ break;
14597
+ }
14269
14598
  } else {
14270
14599
  var decorators = [];
14271
14600
 
14272
14601
  if (this.match(26) && this.hasPlugin("decorators")) {
14273
- this.raise(this.state.start, ErrorMessages.UnsupportedParameterDecorator);
14602
+ this.raise(ErrorMessages.UnsupportedParameterDecorator, {
14603
+ at: this.state.startLoc
14604
+ });
14274
14605
  }
14275
14606
 
14276
14607
  while (this.match(26)) {
@@ -14353,23 +14684,29 @@ class LValParser extends NodeUtils {
14353
14684
  } = expr;
14354
14685
 
14355
14686
  if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(name, this.inModule) : isStrictBindOnlyReservedWord(name))) {
14356
- this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, name);
14687
+ this.raise(bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, {
14688
+ node: expr
14689
+ }, name);
14357
14690
  }
14358
14691
 
14359
14692
  if (checkClashes) {
14360
14693
  if (checkClashes.has(name)) {
14361
- this.raise(expr.start, ErrorMessages.ParamDupe);
14694
+ this.raise(ErrorMessages.ParamDupe, {
14695
+ node: expr
14696
+ });
14362
14697
  } else {
14363
14698
  checkClashes.add(name);
14364
14699
  }
14365
14700
  }
14366
14701
 
14367
14702
  if (disallowLetBinding && name === "let") {
14368
- this.raise(expr.start, ErrorMessages.LetInLexicalBinding);
14703
+ this.raise(ErrorMessages.LetInLexicalBinding, {
14704
+ node: expr
14705
+ });
14369
14706
  }
14370
14707
 
14371
14708
  if (!(bindingType & BIND_NONE)) {
14372
- this.scope.declareName(name, bindingType, expr.start);
14709
+ this.scope.declareName(name, bindingType, expr.loc.start);
14373
14710
  }
14374
14711
 
14375
14712
  break;
@@ -14377,7 +14714,9 @@ class LValParser extends NodeUtils {
14377
14714
 
14378
14715
  case "MemberExpression":
14379
14716
  if (bindingType !== BIND_NONE) {
14380
- this.raise(expr.start, ErrorMessages.InvalidPropertyBindingPattern);
14717
+ this.raise(ErrorMessages.InvalidPropertyBindingPattern, {
14718
+ node: expr
14719
+ });
14381
14720
  }
14382
14721
 
14383
14722
  break;
@@ -14413,33 +14752,30 @@ class LValParser extends NodeUtils {
14413
14752
 
14414
14753
  default:
14415
14754
  {
14416
- this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, contextDescription);
14755
+ this.raise(bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, {
14756
+ node: expr
14757
+ }, contextDescription);
14417
14758
  }
14418
14759
  }
14419
14760
  }
14420
14761
 
14421
14762
  checkToRestConversion(node) {
14422
14763
  if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
14423
- this.raise(node.argument.start, ErrorMessages.InvalidRestAssignmentPattern);
14764
+ this.raise(ErrorMessages.InvalidRestAssignmentPattern, {
14765
+ node: node.argument
14766
+ });
14424
14767
  }
14425
14768
  }
14426
14769
 
14427
14770
  checkCommaAfterRest(close) {
14428
- if (this.match(12)) {
14429
- if (this.lookaheadCharCode() === close) {
14430
- this.raiseTrailingCommaAfterRest(this.state.start);
14431
- } else {
14432
- this.raiseRestNotLast(this.state.start);
14433
- }
14771
+ if (!this.match(12)) {
14772
+ return false;
14434
14773
  }
14435
- }
14436
-
14437
- raiseRestNotLast(pos) {
14438
- throw this.raise(pos, ErrorMessages.ElementAfterRest);
14439
- }
14440
14774
 
14441
- raiseTrailingCommaAfterRest(pos) {
14442
- this.raise(pos, ErrorMessages.RestTrailingComma);
14775
+ this.raise(this.lookaheadCharCode() === close ? ErrorMessages.RestTrailingComma : ErrorMessages.ElementAfterRest, {
14776
+ at: this.state.startLoc
14777
+ });
14778
+ return true;
14443
14779
  }
14444
14780
 
14445
14781
  }
@@ -14457,17 +14793,21 @@ class ExpressionParser extends LValParser {
14457
14793
 
14458
14794
  if (name === "__proto__") {
14459
14795
  if (isRecord) {
14460
- this.raise(key.start, ErrorMessages.RecordNoProto);
14796
+ this.raise(ErrorMessages.RecordNoProto, {
14797
+ node: key
14798
+ });
14461
14799
  return;
14462
14800
  }
14463
14801
 
14464
14802
  if (protoRef.used) {
14465
14803
  if (refExpressionErrors) {
14466
- if (refExpressionErrors.doubleProto === -1) {
14467
- refExpressionErrors.doubleProto = key.start;
14804
+ if (refExpressionErrors.doubleProtoLoc === null) {
14805
+ refExpressionErrors.doubleProtoLoc = key.loc.start;
14468
14806
  }
14469
14807
  } else {
14470
- this.raise(key.start, ErrorMessages.DuplicateProto);
14808
+ this.raise(ErrorMessages.DuplicateProto, {
14809
+ node: key
14810
+ });
14471
14811
  }
14472
14812
  }
14473
14813
 
@@ -14536,9 +14876,9 @@ class ExpressionParser extends LValParser {
14536
14876
  }
14537
14877
 
14538
14878
  setOptionalParametersError(refExpressionErrors, resultError) {
14539
- var _resultError$pos;
14879
+ var _resultError$loc;
14540
14880
 
14541
- refExpressionErrors.optionalParameters = (_resultError$pos = resultError == null ? void 0 : resultError.pos) != null ? _resultError$pos : this.state.start;
14881
+ refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc;
14542
14882
  }
14543
14883
 
14544
14884
  parseMaybeAssign(refExpressionErrors, afterLeftParse) {
@@ -14588,12 +14928,12 @@ class ExpressionParser extends LValParser {
14588
14928
  if (this.match(29)) {
14589
14929
  node.left = this.toAssignable(left, true);
14590
14930
 
14591
- if (refExpressionErrors.doubleProto >= startPos) {
14592
- refExpressionErrors.doubleProto = -1;
14931
+ if (refExpressionErrors.doubleProtoLoc != null && indexes.get(refExpressionErrors.doubleProtoLoc) >= startPos) {
14932
+ refExpressionErrors.doubleProtoLoc = null;
14593
14933
  }
14594
14934
 
14595
- if (refExpressionErrors.shorthandAssign >= startPos) {
14596
- refExpressionErrors.shorthandAssign = -1;
14935
+ if (refExpressionErrors.shorthandAssignLoc != null && indexes.get(refExpressionErrors.shorthandAssignLoc) >= startPos) {
14936
+ refExpressionErrors.shorthandAssignLoc = null;
14597
14937
  }
14598
14938
  } else {
14599
14939
  node.left = left;
@@ -14656,15 +14996,14 @@ class ExpressionParser extends LValParser {
14656
14996
  parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
14657
14997
  if (this.isPrivateName(left)) {
14658
14998
  var value = this.getPrivateNameSV(left);
14659
- var {
14660
- start
14661
- } = left;
14662
14999
 
14663
15000
  if (minPrec >= tokenOperatorPrecedence(54) || !this.prodParam.hasIn || !this.match(54)) {
14664
- this.raise(start, ErrorMessages.PrivateInExpectedIn, value);
15001
+ this.raise(ErrorMessages.PrivateInExpectedIn, {
15002
+ node: left
15003
+ }, value);
14665
15004
  }
14666
15005
 
14667
- this.classScope.usePrivateName(value, start);
15006
+ this.classScope.usePrivateName(value, left.loc.start);
14668
15007
  }
14669
15008
 
14670
15009
  var op = this.state.type;
@@ -14680,7 +15019,7 @@ class ExpressionParser extends LValParser {
14680
15019
  return left;
14681
15020
  }
14682
15021
 
14683
- this.checkPipelineAtInfixOperator(left, leftStartPos);
15022
+ this.checkPipelineAtInfixOperator(left, leftStartLoc);
14684
15023
  }
14685
15024
 
14686
15025
  var node = this.startNodeAt(leftStartPos, leftStartLoc);
@@ -14699,7 +15038,9 @@ class ExpressionParser extends LValParser {
14699
15038
  proposal: "minimal"
14700
15039
  }])) {
14701
15040
  if (this.state.type === 92 && this.prodParam.hasAwait) {
14702
- throw this.raise(this.state.start, ErrorMessages.UnexpectedAwaitAfterPipelineBody);
15041
+ throw this.raise(ErrorMessages.UnexpectedAwaitAfterPipelineBody, {
15042
+ at: this.state.startLoc
15043
+ });
14703
15044
  }
14704
15045
  }
14705
15046
 
@@ -14708,7 +15049,9 @@ class ExpressionParser extends LValParser {
14708
15049
  var nextOp = this.state.type;
14709
15050
 
14710
15051
  if (coalesce && (nextOp === 39 || nextOp === 40) || logical && nextOp === 38) {
14711
- throw this.raise(this.state.start, ErrorMessages.MixingCoalesceWithLogical);
15052
+ throw this.raise(ErrorMessages.MixingCoalesceWithLogical, {
15053
+ at: this.state.startLoc
15054
+ });
14712
15055
  }
14713
15056
 
14714
15057
  return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
@@ -14733,7 +15076,9 @@ class ExpressionParser extends LValParser {
14733
15076
  case "smart":
14734
15077
  return this.withTopicBindingContext(() => {
14735
15078
  if (this.prodParam.hasYield && this.isContextual(101)) {
14736
- throw this.raise(this.state.start, ErrorMessages.PipeBodyIsTighter, this.state.value);
15079
+ throw this.raise(ErrorMessages.PipeBodyIsTighter, {
15080
+ at: this.state.startLoc
15081
+ }, this.state.value);
14737
15082
  }
14738
15083
 
14739
15084
  return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startPos, startLoc);
@@ -14760,16 +15105,20 @@ class ExpressionParser extends LValParser {
14760
15105
  var _body$extra;
14761
15106
 
14762
15107
  var {
14763
- start
15108
+ startLoc
14764
15109
  } = this.state;
14765
15110
  var body = this.parseMaybeAssign();
14766
15111
 
14767
15112
  if (invalidHackPipeBodies.has(body.type) && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) {
14768
- this.raise(start, ErrorMessages.PipeUnparenthesizedBody, invalidHackPipeBodies.get(body.type));
15113
+ this.raise(ErrorMessages.PipeUnparenthesizedBody, {
15114
+ at: startLoc
15115
+ }, invalidHackPipeBodies.get(body.type));
14769
15116
  }
14770
15117
 
14771
15118
  if (!this.topicReferenceWasUsedInCurrentContext()) {
14772
- this.raise(start, ErrorMessages.PipeTopicUnused);
15119
+ this.raise(ErrorMessages.PipeTopicUnused, {
15120
+ at: startLoc
15121
+ });
14773
15122
  }
14774
15123
 
14775
15124
  return body;
@@ -14777,7 +15126,9 @@ class ExpressionParser extends LValParser {
14777
15126
 
14778
15127
  checkExponentialAfterUnary(node) {
14779
15128
  if (this.match(53)) {
14780
- this.raise(node.argument.start, ErrorMessages.UnexpectedTokenUnaryExponentiation);
15129
+ this.raise(ErrorMessages.UnexpectedTokenUnaryExponentiation, {
15130
+ node: node.argument
15131
+ });
14781
15132
  }
14782
15133
  }
14783
15134
 
@@ -14815,9 +15166,13 @@ class ExpressionParser extends LValParser {
14815
15166
  var arg = node.argument;
14816
15167
 
14817
15168
  if (arg.type === "Identifier") {
14818
- this.raise(node.start, ErrorMessages.StrictDelete);
15169
+ this.raise(ErrorMessages.StrictDelete, {
15170
+ node
15171
+ });
14819
15172
  } else if (this.hasPropertyAsPrivateName(arg)) {
14820
- this.raise(node.start, ErrorMessages.DeletePrivateField);
15173
+ this.raise(ErrorMessages.DeletePrivateField, {
15174
+ node
15175
+ });
14821
15176
  }
14822
15177
  }
14823
15178
 
@@ -14837,7 +15192,7 @@ class ExpressionParser extends LValParser {
14837
15192
  var _startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(50);
14838
15193
 
14839
15194
  if (_startsExpr && !this.isAmbiguousAwait()) {
14840
- this.raiseOverwrite(startPos, ErrorMessages.AwaitNotInAsyncContext);
15195
+ this.raiseOverwrite(startLoc, ErrorMessages.AwaitNotInAsyncContext);
14841
15196
  return this.parseAwait(startPos, startLoc);
14842
15197
  }
14843
15198
  }
@@ -14945,10 +15300,12 @@ class ExpressionParser extends LValParser {
14945
15300
  this.expect(3);
14946
15301
  } else if (this.match(130)) {
14947
15302
  if (base.type === "Super") {
14948
- this.raise(startPos, ErrorMessages.SuperPrivateField);
15303
+ this.raise(ErrorMessages.SuperPrivateField, {
15304
+ at: startLoc
15305
+ });
14949
15306
  }
14950
15307
 
14951
- this.classScope.usePrivateName(this.state.value, this.state.start);
15308
+ this.classScope.usePrivateName(this.state.value, this.state.startLoc);
14952
15309
  node.property = this.parsePrivateName();
14953
15310
  } else {
14954
15311
  node.property = this.parseIdentifier(true);
@@ -15024,14 +15381,16 @@ class ExpressionParser extends LValParser {
15024
15381
  node.quasi = this.parseTemplate(true);
15025
15382
 
15026
15383
  if (state.optionalChainMember) {
15027
- this.raise(startPos, ErrorMessages.OptionalChainingNoTemplate);
15384
+ this.raise(ErrorMessages.OptionalChainingNoTemplate, {
15385
+ at: startLoc
15386
+ });
15028
15387
  }
15029
15388
 
15030
15389
  return this.finishNode(node, "TaggedTemplateExpression");
15031
15390
  }
15032
15391
 
15033
15392
  atPossibleAsyncArrow(base) {
15034
- return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
15393
+ return base.type === "Identifier" && base.name === "async" && indexes.get(this.state.lastTokEndLoc) === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
15035
15394
  }
15036
15395
 
15037
15396
  finishCallExpression(node, optional) {
@@ -15045,11 +15404,15 @@ class ExpressionParser extends LValParser {
15045
15404
  }
15046
15405
 
15047
15406
  if (node.arguments.length === 0 || node.arguments.length > 2) {
15048
- this.raise(node.start, ErrorMessages.ImportCallArity, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
15407
+ this.raise(ErrorMessages.ImportCallArity, {
15408
+ node
15409
+ }, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
15049
15410
  } else {
15050
15411
  for (var arg of node.arguments) {
15051
15412
  if (arg.type === "SpreadElement") {
15052
- this.raise(arg.start, ErrorMessages.ImportCallSpreadArgument);
15413
+ this.raise(ErrorMessages.ImportCallSpreadArgument, {
15414
+ node: arg
15415
+ });
15053
15416
  }
15054
15417
  }
15055
15418
  }
@@ -15072,11 +15435,13 @@ class ExpressionParser extends LValParser {
15072
15435
 
15073
15436
  if (this.match(close)) {
15074
15437
  if (dynamicImport && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
15075
- this.raise(this.state.lastTokStart, ErrorMessages.ImportCallArgumentTrailingComma);
15438
+ this.raise(ErrorMessages.ImportCallArgumentTrailingComma, {
15439
+ at: this.state.lastTokStartLoc
15440
+ });
15076
15441
  }
15077
15442
 
15078
15443
  if (nodeForExtra) {
15079
- this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
15444
+ this.addTrailingCommaExtraToNode(nodeForExtra);
15080
15445
  }
15081
15446
 
15082
15447
  this.next();
@@ -15100,7 +15465,7 @@ class ExpressionParser extends LValParser {
15100
15465
 
15101
15466
  this.resetPreviousNodeTrailingComments(call);
15102
15467
  this.expect(19);
15103
- this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingComma);
15468
+ this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc);
15104
15469
 
15105
15470
  if (call.innerComments) {
15106
15471
  setInnerComments(node, call.innerComments);
@@ -15138,7 +15503,9 @@ class ExpressionParser extends LValParser {
15138
15503
  }
15139
15504
 
15140
15505
  if (!this.match(10)) {
15141
- this.raise(this.state.lastTokStart, ErrorMessages.UnsupportedImport);
15506
+ this.raise(ErrorMessages.UnsupportedImport, {
15507
+ at: this.state.lastTokStartLoc
15508
+ });
15142
15509
  }
15143
15510
 
15144
15511
  return this.finishNode(node, "Import");
@@ -15237,13 +15604,17 @@ class ExpressionParser extends LValParser {
15237
15604
  if (callee.type === "MemberExpression") {
15238
15605
  return this.finishNode(node, "BindExpression");
15239
15606
  } else {
15240
- throw this.raise(callee.start, ErrorMessages.UnsupportedBind);
15607
+ throw this.raise(ErrorMessages.UnsupportedBind, {
15608
+ node: callee
15609
+ });
15241
15610
  }
15242
15611
  }
15243
15612
 
15244
15613
  case 130:
15245
15614
  {
15246
- this.raise(this.state.start, ErrorMessages.PrivateInExpectedIn, this.state.value);
15615
+ this.raise(ErrorMessages.PrivateInExpectedIn, {
15616
+ at: this.state.startLoc
15617
+ }, this.state.value);
15247
15618
  return this.parsePrivateName();
15248
15619
  }
15249
15620
 
@@ -15335,7 +15706,7 @@ class ExpressionParser extends LValParser {
15335
15706
  this.state.value = topicTokenValue;
15336
15707
  this.state.pos--;
15337
15708
  this.state.end--;
15338
- this.state.endLoc.column--;
15709
+ this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1);
15339
15710
  return this.parseTopicReference(pipeProposal);
15340
15711
  } else {
15341
15712
  throw this.unexpected();
@@ -15344,38 +15715,32 @@ class ExpressionParser extends LValParser {
15344
15715
 
15345
15716
  parseTopicReference(pipeProposal) {
15346
15717
  var node = this.startNode();
15347
- var start = this.state.start;
15718
+ var startLoc = this.state.startLoc;
15348
15719
  var tokenType = this.state.type;
15349
15720
  this.next();
15350
- return this.finishTopicReference(node, start, pipeProposal, tokenType);
15721
+ return this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
15351
15722
  }
15352
15723
 
15353
- finishTopicReference(node, start, pipeProposal, tokenType) {
15354
- if (this.testTopicReferenceConfiguration(pipeProposal, start, tokenType)) {
15355
- var nodeType;
15356
-
15357
- if (pipeProposal === "smart") {
15358
- nodeType = "PipelinePrimaryTopicReference";
15359
- } else {
15360
- nodeType = "TopicReference";
15361
- }
15724
+ finishTopicReference(node, startLoc, pipeProposal, tokenType) {
15725
+ if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) {
15726
+ var nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference";
15362
15727
 
15363
15728
  if (!this.topicReferenceIsAllowedInCurrentContext()) {
15364
- if (pipeProposal === "smart") {
15365
- this.raise(start, ErrorMessages.PrimaryTopicNotAllowed);
15366
- } else {
15367
- this.raise(start, ErrorMessages.PipeTopicUnbound);
15368
- }
15729
+ this.raise(pipeProposal === "smart" ? ErrorMessages.PrimaryTopicNotAllowed : ErrorMessages.PipeTopicUnbound, {
15730
+ at: startLoc
15731
+ });
15369
15732
  }
15370
15733
 
15371
15734
  this.registerTopicReference();
15372
15735
  return this.finishNode(node, nodeType);
15373
15736
  } else {
15374
- throw this.raise(start, ErrorMessages.PipeTopicUnconfiguredToken, tokenLabelName(tokenType));
15737
+ throw this.raise(ErrorMessages.PipeTopicUnconfiguredToken, {
15738
+ at: startLoc
15739
+ }, tokenLabelName(tokenType));
15375
15740
  }
15376
15741
  }
15377
15742
 
15378
- testTopicReferenceConfiguration(pipeProposal, start, tokenType) {
15743
+ testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
15379
15744
  switch (pipeProposal) {
15380
15745
  case "hack":
15381
15746
  {
@@ -15388,7 +15753,9 @@ class ExpressionParser extends LValParser {
15388
15753
  return tokenType === 27;
15389
15754
 
15390
15755
  default:
15391
- throw this.raise(start, ErrorMessages.PipeTopicRequiresHackPipes);
15756
+ throw this.raise(ErrorMessages.PipeTopicRequiresHackPipes, {
15757
+ at: startLoc
15758
+ });
15392
15759
  }
15393
15760
  }
15394
15761
 
@@ -15398,7 +15765,9 @@ class ExpressionParser extends LValParser {
15398
15765
  this.prodParam.exit();
15399
15766
 
15400
15767
  if (this.hasPrecedingLineBreak()) {
15401
- this.raise(this.state.pos, ErrorMessages.LineTerminatorBeforeArrow);
15768
+ this.raise(ErrorMessages.LineTerminatorBeforeArrow, {
15769
+ at: this.state.curPosition()
15770
+ });
15402
15771
  }
15403
15772
 
15404
15773
  this.expect(19);
@@ -15435,13 +15804,19 @@ class ExpressionParser extends LValParser {
15435
15804
  this.next();
15436
15805
 
15437
15806
  if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
15438
- this.raise(node.start, ErrorMessages.SuperNotAllowed);
15807
+ this.raise(ErrorMessages.SuperNotAllowed, {
15808
+ node
15809
+ });
15439
15810
  } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
15440
- this.raise(node.start, ErrorMessages.UnexpectedSuper);
15811
+ this.raise(ErrorMessages.UnexpectedSuper, {
15812
+ node
15813
+ });
15441
15814
  }
15442
15815
 
15443
15816
  if (!this.match(10) && !this.match(0) && !this.match(16)) {
15444
- this.raise(node.start, ErrorMessages.UnsupportedSuper);
15817
+ this.raise(ErrorMessages.UnsupportedSuper, {
15818
+ node
15819
+ });
15445
15820
  }
15446
15821
 
15447
15822
  return this.finishNode(node, "Super");
@@ -15449,7 +15824,7 @@ class ExpressionParser extends LValParser {
15449
15824
 
15450
15825
  parsePrivateName() {
15451
15826
  var node = this.startNode();
15452
- var id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart));
15827
+ var id = this.startNodeAt(this.state.start + 1, new Position(this.state.curLine, this.state.start + 1 - this.state.lineStart, this.state.start + 1));
15453
15828
  var name = this.state.value;
15454
15829
  this.next();
15455
15830
  node.id = this.createIdentifier(id, name);
@@ -15482,7 +15857,9 @@ class ExpressionParser extends LValParser {
15482
15857
  node.property = this.parseIdentifier(true);
15483
15858
 
15484
15859
  if (node.property.name !== propertyName || containsEsc) {
15485
- this.raise(node.property.start, ErrorMessages.UnsupportedMetaProperty, meta.name, propertyName);
15860
+ this.raise(ErrorMessages.UnsupportedMetaProperty, {
15861
+ node: node.property
15862
+ }, meta.name, propertyName);
15486
15863
  }
15487
15864
 
15488
15865
  return this.finishNode(node, "MetaProperty");
@@ -15494,7 +15871,9 @@ class ExpressionParser extends LValParser {
15494
15871
 
15495
15872
  if (this.isContextual(96)) {
15496
15873
  if (!this.inModule) {
15497
- this.raise(id.start, SourceTypeModuleErrorMessages.ImportMetaOutsideModule);
15874
+ this.raise(SourceTypeModuleErrorMessages.ImportMetaOutsideModule, {
15875
+ node: id
15876
+ });
15498
15877
  }
15499
15878
 
15500
15879
  this.sawUnambiguousESM = true;
@@ -15567,17 +15946,17 @@ class ExpressionParser extends LValParser {
15567
15946
  var exprList = [];
15568
15947
  var refExpressionErrors = new ExpressionErrors();
15569
15948
  var first = true;
15570
- var spreadStart;
15571
- var optionalCommaStart;
15949
+ var spreadStartLoc;
15950
+ var optionalCommaStartLoc;
15572
15951
 
15573
15952
  while (!this.match(11)) {
15574
15953
  if (first) {
15575
15954
  first = false;
15576
15955
  } else {
15577
- this.expect(12, refExpressionErrors.optionalParameters === -1 ? null : refExpressionErrors.optionalParameters);
15956
+ this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc);
15578
15957
 
15579
15958
  if (this.match(11)) {
15580
- optionalCommaStart = this.state.start;
15959
+ optionalCommaStartLoc = this.state.startLoc;
15581
15960
  break;
15582
15961
  }
15583
15962
  }
@@ -15585,16 +15964,17 @@ class ExpressionParser extends LValParser {
15585
15964
  if (this.match(21)) {
15586
15965
  var spreadNodeStartPos = this.state.start;
15587
15966
  var spreadNodeStartLoc = this.state.startLoc;
15588
- spreadStart = this.state.start;
15967
+ spreadStartLoc = this.state.startLoc;
15589
15968
  exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
15590
- this.checkCommaAfterRest(41);
15591
- break;
15969
+
15970
+ if (!this.checkCommaAfterRest(41)) {
15971
+ break;
15972
+ }
15592
15973
  } else {
15593
15974
  exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem));
15594
15975
  }
15595
15976
  }
15596
15977
 
15597
- var innerEndPos = this.state.lastTokEnd;
15598
15978
  var innerEndLoc = this.state.lastTokEndLoc;
15599
15979
  this.expect(11);
15600
15980
  this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
@@ -15611,11 +15991,11 @@ class ExpressionParser extends LValParser {
15611
15991
  this.expressionScope.exit();
15612
15992
 
15613
15993
  if (!exprList.length) {
15614
- this.unexpected(this.state.lastTokStart);
15994
+ this.unexpected(this.state.lastTokStartLoc);
15615
15995
  }
15616
15996
 
15617
- if (optionalCommaStart) this.unexpected(optionalCommaStart);
15618
- if (spreadStart) this.unexpected(spreadStart);
15997
+ if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc);
15998
+ if (spreadStartLoc) this.unexpected(spreadStartLoc);
15619
15999
  this.checkExpressionErrors(refExpressionErrors, true);
15620
16000
  this.toReferencedListDeep(exprList, true);
15621
16001
 
@@ -15623,7 +16003,7 @@ class ExpressionParser extends LValParser {
15623
16003
  val = this.startNodeAt(innerStartPos, innerStartLoc);
15624
16004
  val.expressions = exprList;
15625
16005
  this.finishNode(val, "SequenceExpression");
15626
- this.resetEndLocation(val, innerEndPos, innerEndLoc);
16006
+ this.resetEndLocation(val, innerEndLoc);
15627
16007
  } else {
15628
16008
  val = exprList[0];
15629
16009
  }
@@ -15631,7 +16011,7 @@ class ExpressionParser extends LValParser {
15631
16011
  if (!this.options.createParenthesizedExpressions) {
15632
16012
  this.addExtra(val, "parenthesized", true);
15633
16013
  this.addExtra(val, "parenStart", startPos);
15634
- this.takeSurroundingComments(val, startPos, this.state.lastTokEnd);
16014
+ this.takeSurroundingComments(val, startPos, indexes.get(this.state.lastTokEndLoc));
15635
16015
  return val;
15636
16016
  }
15637
16017
 
@@ -15665,7 +16045,9 @@ class ExpressionParser extends LValParser {
15665
16045
  var metaProp = this.parseMetaProperty(node, meta, "target");
15666
16046
 
15667
16047
  if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
15668
- this.raise(metaProp.start, ErrorMessages.UnexpectedNewTarget);
16048
+ this.raise(ErrorMessages.UnexpectedNewTarget, {
16049
+ node: metaProp
16050
+ });
15669
16051
  }
15670
16052
 
15671
16053
  return metaProp;
@@ -15678,11 +16060,17 @@ class ExpressionParser extends LValParser {
15678
16060
  node.callee = this.parseNoCallExpr();
15679
16061
 
15680
16062
  if (node.callee.type === "Import") {
15681
- this.raise(node.callee.start, ErrorMessages.ImportCallNotNewExpression);
16063
+ this.raise(ErrorMessages.ImportCallNotNewExpression, {
16064
+ node: node.callee
16065
+ });
15682
16066
  } else if (this.isOptionalChain(node.callee)) {
15683
- this.raise(this.state.lastTokEnd, ErrorMessages.OptionalChainingNoNew);
16067
+ this.raise(ErrorMessages.OptionalChainingNoNew, {
16068
+ at: this.state.lastTokEndLoc
16069
+ });
15684
16070
  } else if (this.eat(18)) {
15685
- this.raise(this.state.start, ErrorMessages.OptionalChainingNoNew);
16071
+ this.raise(ErrorMessages.OptionalChainingNoNew, {
16072
+ at: this.state.startLoc
16073
+ });
15686
16074
  }
15687
16075
 
15688
16076
  this.parseNewArguments(node);
@@ -15702,15 +16090,18 @@ class ExpressionParser extends LValParser {
15702
16090
  parseTemplateElement(isTagged) {
15703
16091
  var {
15704
16092
  start,
16093
+ startLoc,
15705
16094
  end,
15706
16095
  value
15707
16096
  } = this.state;
15708
16097
  var elemStart = start + 1;
15709
- var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(this.state.startLoc, 1));
16098
+ var elem = this.startNodeAt(elemStart, createPositionWithColumnOffset(startLoc, 1));
15710
16099
 
15711
16100
  if (value === null) {
15712
16101
  if (!isTagged) {
15713
- this.raise(start + 2, ErrorMessages.InvalidEscapeSequenceTemplate);
16102
+ this.raise(ErrorMessages.InvalidEscapeSequenceTemplate, {
16103
+ at: createPositionWithColumnOffset(startLoc, 2)
16104
+ });
15714
16105
  }
15715
16106
  }
15716
16107
 
@@ -15724,7 +16115,7 @@ class ExpressionParser extends LValParser {
15724
16115
  elem.tail = isTail;
15725
16116
  this.next();
15726
16117
  this.finishNode(elem, "TemplateElement");
15727
- this.resetEndLocation(elem, elemEnd, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
16118
+ this.resetEndLocation(elem, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset));
15728
16119
  return elem;
15729
16120
  }
15730
16121
 
@@ -15767,7 +16158,7 @@ class ExpressionParser extends LValParser {
15767
16158
  this.expect(12);
15768
16159
 
15769
16160
  if (this.match(close)) {
15770
- this.addExtra(node, "trailingComma", this.state.lastTokStart);
16161
+ this.addTrailingCommaExtraToNode(node);
15771
16162
  break;
15772
16163
  }
15773
16164
  }
@@ -15782,7 +16173,9 @@ class ExpressionParser extends LValParser {
15782
16173
  }
15783
16174
 
15784
16175
  if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
15785
- this.raise(prop.start, ErrorMessages.InvalidRecordProperty);
16176
+ this.raise(ErrorMessages.InvalidRecordProperty, {
16177
+ node: prop
16178
+ });
15786
16179
  }
15787
16180
 
15788
16181
  if (prop.shorthand) {
@@ -15805,6 +16198,11 @@ class ExpressionParser extends LValParser {
15805
16198
  return this.finishNode(node, type);
15806
16199
  }
15807
16200
 
16201
+ addTrailingCommaExtraToNode(node) {
16202
+ this.addExtra(node, "trailingComma", this.state.lastTokStart);
16203
+ this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false);
16204
+ }
16205
+
15808
16206
  maybeAsyncOrAccessorProp(prop) {
15809
16207
  return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(51));
15810
16208
  }
@@ -15814,7 +16212,9 @@ class ExpressionParser extends LValParser {
15814
16212
 
15815
16213
  if (this.match(26)) {
15816
16214
  if (this.hasPlugin("decorators")) {
15817
- this.raise(this.state.start, ErrorMessages.UnsupportedPropertyDecorator);
16215
+ this.raise(ErrorMessages.UnsupportedPropertyDecorator, {
16216
+ at: this.state.startLoc
16217
+ });
15818
16218
  }
15819
16219
 
15820
16220
  while (this.match(26)) {
@@ -15867,7 +16267,9 @@ class ExpressionParser extends LValParser {
15867
16267
 
15868
16268
  if (this.match(51)) {
15869
16269
  isGenerator = true;
15870
- this.raise(this.state.pos, ErrorMessages.AccessorIsGenerator, keyName);
16270
+ this.raise(ErrorMessages.AccessorIsGenerator, {
16271
+ at: this.state.curPosition()
16272
+ }, keyName);
15871
16273
  this.next();
15872
16274
  }
15873
16275
 
@@ -15892,18 +16294,17 @@ class ExpressionParser extends LValParser {
15892
16294
 
15893
16295
  var paramCount = this.getGetterSetterExpectedParamCount(method);
15894
16296
  var params = this.getObjectOrClassMethodParams(method);
15895
- var start = method.start;
15896
16297
 
15897
16298
  if (params.length !== paramCount) {
15898
- if (method.kind === "get") {
15899
- this.raise(start, ErrorMessages.BadGetterArity);
15900
- } else {
15901
- this.raise(start, ErrorMessages.BadSetterArity);
15902
- }
16299
+ this.raise(method.kind === "get" ? ErrorMessages.BadGetterArity : ErrorMessages.BadSetterArity, {
16300
+ node: method
16301
+ });
15903
16302
  }
15904
16303
 
15905
16304
  if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
15906
- this.raise(start, ErrorMessages.BadSetterRestParameter);
16305
+ this.raise(ErrorMessages.BadSetterRestParameter, {
16306
+ node: method
16307
+ });
15907
16308
  }
15908
16309
  }
15909
16310
 
@@ -15931,19 +16332,21 @@ class ExpressionParser extends LValParser {
15931
16332
  }
15932
16333
 
15933
16334
  if (!prop.computed && prop.key.type === "Identifier") {
15934
- this.checkReservedWord(prop.key.name, prop.key.start, true, false);
16335
+ this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false);
15935
16336
 
15936
16337
  if (isPattern) {
15937
16338
  prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
15938
16339
  } else if (this.match(29)) {
15939
- var shorthandAssign = this.state.start;
16340
+ var shorthandAssignLoc = this.state.startLoc;
15940
16341
 
15941
16342
  if (refExpressionErrors != null) {
15942
- if (refExpressionErrors.shorthandAssign === -1) {
15943
- refExpressionErrors.shorthandAssign = shorthandAssign;
16343
+ if (refExpressionErrors.shorthandAssignLoc === null) {
16344
+ refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc;
15944
16345
  }
15945
16346
  } else {
15946
- this.raise(shorthandAssign, ErrorMessages.InvalidCoverInitializedName);
16347
+ this.raise(ErrorMessages.InvalidCoverInitializedName, {
16348
+ at: shorthandAssignLoc
16349
+ });
15947
16350
  }
15948
16351
 
15949
16352
  prop.value = this.parseMaybeDefault(startPos, startLoc, cloneIdentifier(prop.key));
@@ -15996,8 +16399,9 @@ class ExpressionParser extends LValParser {
15996
16399
 
15997
16400
  case 130:
15998
16401
  {
15999
- var privateKeyPos = this.state.start + 1;
16000
- this.raise(privateKeyPos, ErrorMessages.UnexpectedPrivateField);
16402
+ this.raise(ErrorMessages.UnexpectedPrivateField, {
16403
+ at: createPositionWithColumnOffset(this.state.startLoc, 1)
16404
+ });
16001
16405
  key = this.parsePrivateName();
16002
16406
  break;
16003
16407
  }
@@ -16051,11 +16455,11 @@ class ExpressionParser extends LValParser {
16051
16455
  return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
16052
16456
  }
16053
16457
 
16054
- parseArrowExpression(node, params, isAsync, trailingCommaPos) {
16458
+ parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
16055
16459
  this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
16056
16460
  var flags = functionFlags(isAsync, false);
16057
16461
 
16058
- if (!this.match(0) && this.prodParam.hasIn) {
16462
+ if (!this.match(5) && this.prodParam.hasIn) {
16059
16463
  flags |= PARAM_IN;
16060
16464
  }
16061
16465
 
@@ -16065,7 +16469,7 @@ class ExpressionParser extends LValParser {
16065
16469
 
16066
16470
  if (params) {
16067
16471
  this.state.maybeInArrowParameters = true;
16068
- this.setArrowFunctionParameters(node, params, trailingCommaPos);
16472
+ this.setArrowFunctionParameters(node, params, trailingCommaLoc);
16069
16473
  }
16070
16474
 
16071
16475
  this.state.maybeInArrowParameters = false;
@@ -16076,8 +16480,8 @@ class ExpressionParser extends LValParser {
16076
16480
  return this.finishNode(node, "ArrowFunctionExpression");
16077
16481
  }
16078
16482
 
16079
- setArrowFunctionParameters(node, params, trailingCommaPos) {
16080
- node.params = this.toAssignableList(params, trailingCommaPos, false);
16483
+ setArrowFunctionParameters(node, params, trailingCommaLoc) {
16484
+ node.params = this.toAssignableList(params, trailingCommaLoc, false);
16081
16485
  }
16082
16486
 
16083
16487
  parseFunctionBodyAndFinish(node, type) {
@@ -16103,8 +16507,12 @@ class ExpressionParser extends LValParser {
16103
16507
  var nonSimple = !this.isSimpleParamList(node.params);
16104
16508
 
16105
16509
  if (hasStrictModeDirective && nonSimple) {
16106
- var errorPos = (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.end : node.start;
16107
- this.raise(errorPos, ErrorMessages.IllegalLanguageModeDirective);
16510
+ var errorOrigin = (node.kind === "method" || node.kind === "constructor") && !!node.key ? {
16511
+ at: node.key.loc.end
16512
+ } : {
16513
+ node
16514
+ };
16515
+ this.raise(ErrorMessages.IllegalLanguageModeDirective, errorOrigin);
16108
16516
  }
16109
16517
 
16110
16518
  var strictModeChanged = !oldStrict && this.state.strict;
@@ -16150,7 +16558,7 @@ class ExpressionParser extends LValParser {
16150
16558
 
16151
16559
  if (this.match(close)) {
16152
16560
  if (nodeForExtra) {
16153
- this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
16561
+ this.addTrailingCommaExtraToNode(nodeForExtra);
16154
16562
  }
16155
16563
 
16156
16564
  this.next();
@@ -16169,7 +16577,9 @@ class ExpressionParser extends LValParser {
16169
16577
 
16170
16578
  if (this.match(12)) {
16171
16579
  if (!allowEmpty) {
16172
- this.raise(this.state.pos, ErrorMessages.UnexpectedToken, ",");
16580
+ this.raise(ErrorMessages.UnexpectedToken, {
16581
+ at: this.state.curPosition()
16582
+ }, ",");
16173
16583
  }
16174
16584
 
16175
16585
  elt = null;
@@ -16181,7 +16591,9 @@ class ExpressionParser extends LValParser {
16181
16591
  this.expectPlugin("partialApplication");
16182
16592
 
16183
16593
  if (!allowPlaceholder) {
16184
- this.raise(this.state.start, ErrorMessages.UnexpectedArgumentPlaceholder);
16594
+ this.raise(ErrorMessages.UnexpectedArgumentPlaceholder, {
16595
+ at: this.state.startLoc
16596
+ });
16185
16597
  }
16186
16598
 
16187
16599
  var node = this.startNode();
@@ -16209,7 +16621,7 @@ class ExpressionParser extends LValParser {
16209
16621
  parseIdentifierName(pos, liberal) {
16210
16622
  var name;
16211
16623
  var {
16212
- start,
16624
+ startLoc,
16213
16625
  type
16214
16626
  } = this.state;
16215
16627
 
@@ -16226,7 +16638,7 @@ class ExpressionParser extends LValParser {
16226
16638
  this.replaceToken(124);
16227
16639
  }
16228
16640
  } else {
16229
- this.checkReservedWord(name, start, tokenIsKeyword, false);
16641
+ this.checkReservedWord(name, startLoc, tokenIsKeyword, false);
16230
16642
  }
16231
16643
 
16232
16644
  this.next();
@@ -16244,35 +16656,49 @@ class ExpressionParser extends LValParser {
16244
16656
 
16245
16657
  if (word === "yield") {
16246
16658
  if (this.prodParam.hasYield) {
16247
- this.raise(startLoc, ErrorMessages.YieldBindingIdentifier);
16659
+ this.raise(ErrorMessages.YieldBindingIdentifier, {
16660
+ at: startLoc
16661
+ });
16248
16662
  return;
16249
16663
  }
16250
16664
  } else if (word === "await") {
16251
16665
  if (this.prodParam.hasAwait) {
16252
- this.raise(startLoc, ErrorMessages.AwaitBindingIdentifier);
16666
+ this.raise(ErrorMessages.AwaitBindingIdentifier, {
16667
+ at: startLoc
16668
+ });
16253
16669
  return;
16254
- } else if (this.scope.inStaticBlock) {
16255
- this.raise(startLoc, ErrorMessages.AwaitBindingIdentifierInStaticBlock);
16670
+ }
16671
+
16672
+ if (this.scope.inStaticBlock) {
16673
+ this.raise(ErrorMessages.AwaitBindingIdentifierInStaticBlock, {
16674
+ at: startLoc
16675
+ });
16256
16676
  return;
16257
- } else {
16258
- this.expressionScope.recordAsyncArrowParametersError(startLoc, ErrorMessages.AwaitBindingIdentifier);
16259
16677
  }
16678
+
16679
+ this.expressionScope.recordAsyncArrowParametersError(ErrorMessages.AwaitBindingIdentifier, startLoc);
16260
16680
  } else if (word === "arguments") {
16261
16681
  if (this.scope.inClassAndNotInNonArrowFunction) {
16262
- this.raise(startLoc, ErrorMessages.ArgumentsInClass);
16682
+ this.raise(ErrorMessages.ArgumentsInClass, {
16683
+ at: startLoc
16684
+ });
16263
16685
  return;
16264
16686
  }
16265
16687
  }
16266
16688
 
16267
16689
  if (checkKeywords && isKeyword(word)) {
16268
- this.raise(startLoc, ErrorMessages.UnexpectedKeyword, word);
16690
+ this.raise(ErrorMessages.UnexpectedKeyword, {
16691
+ at: startLoc
16692
+ }, word);
16269
16693
  return;
16270
16694
  }
16271
16695
 
16272
16696
  var reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
16273
16697
 
16274
16698
  if (reservedTest(word, this.inModule)) {
16275
- this.raise(startLoc, ErrorMessages.UnexpectedReservedWord, word);
16699
+ this.raise(ErrorMessages.UnexpectedReservedWord, {
16700
+ at: startLoc
16701
+ }, word);
16276
16702
  }
16277
16703
  }
16278
16704
 
@@ -16288,10 +16714,12 @@ class ExpressionParser extends LValParser {
16288
16714
 
16289
16715
  parseAwait(startPos, startLoc) {
16290
16716
  var node = this.startNodeAt(startPos, startLoc);
16291
- this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.AwaitExpressionFormalParameter);
16717
+ this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.AwaitExpressionFormalParameter);
16292
16718
 
16293
16719
  if (this.eat(51)) {
16294
- this.raise(node.start, ErrorMessages.ObsoleteAwaitStar);
16720
+ this.raise(ErrorMessages.ObsoleteAwaitStar, {
16721
+ node
16722
+ });
16295
16723
  }
16296
16724
 
16297
16725
  if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
@@ -16319,7 +16747,7 @@ class ExpressionParser extends LValParser {
16319
16747
 
16320
16748
  parseYield() {
16321
16749
  var node = this.startNode();
16322
- this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.YieldInParameter);
16750
+ this.expressionScope.recordParameterInitializerError(node.loc.start, ErrorMessages.YieldInParameter);
16323
16751
  this.next();
16324
16752
  var delegating = false;
16325
16753
  var argument = null;
@@ -16348,22 +16776,18 @@ class ExpressionParser extends LValParser {
16348
16776
  return this.finishNode(node, "YieldExpression");
16349
16777
  }
16350
16778
 
16351
- checkPipelineAtInfixOperator(left, leftStartPos) {
16779
+ checkPipelineAtInfixOperator(left, leftStartLoc) {
16352
16780
  if (this.hasPlugin(["pipelineOperator", {
16353
16781
  proposal: "smart"
16354
16782
  }])) {
16355
16783
  if (left.type === "SequenceExpression") {
16356
- this.raise(leftStartPos, ErrorMessages.PipelineHeadSequenceExpression);
16784
+ this.raise(ErrorMessages.PipelineHeadSequenceExpression, {
16785
+ at: leftStartLoc
16786
+ });
16357
16787
  }
16358
16788
  }
16359
16789
  }
16360
16790
 
16361
- checkHackPipeBodyEarlyErrors(startPos) {
16362
- if (!this.topicReferenceWasUsedInCurrentContext()) {
16363
- this.raise(startPos, ErrorMessages.PipeTopicUnused);
16364
- }
16365
- }
16366
-
16367
16791
  parseSmartPipelineBodyInStyle(childExpr, startPos, startLoc) {
16368
16792
  var bodyNode = this.startNodeAt(startPos, startLoc);
16369
16793
 
@@ -16371,7 +16795,7 @@ class ExpressionParser extends LValParser {
16371
16795
  bodyNode.callee = childExpr;
16372
16796
  return this.finishNode(bodyNode, "PipelineBareFunction");
16373
16797
  } else {
16374
- this.checkSmartPipeTopicBodyEarlyErrors(startPos);
16798
+ this.checkSmartPipeTopicBodyEarlyErrors(startLoc);
16375
16799
  bodyNode.expression = childExpr;
16376
16800
  return this.finishNode(bodyNode, "PipelineTopicExpression");
16377
16801
  }
@@ -16390,11 +16814,17 @@ class ExpressionParser extends LValParser {
16390
16814
  }
16391
16815
  }
16392
16816
 
16393
- checkSmartPipeTopicBodyEarlyErrors(startPos) {
16817
+ checkSmartPipeTopicBodyEarlyErrors(startLoc) {
16394
16818
  if (this.match(19)) {
16395
- throw this.raise(this.state.start, ErrorMessages.PipelineBodyNoArrow);
16396
- } else if (!this.topicReferenceWasUsedInCurrentContext()) {
16397
- this.raise(startPos, ErrorMessages.PipelineTopicUnused);
16819
+ throw this.raise(ErrorMessages.PipelineBodyNoArrow, {
16820
+ at: this.state.startLoc
16821
+ });
16822
+ }
16823
+
16824
+ if (!this.topicReferenceWasUsedInCurrentContext()) {
16825
+ this.raise(ErrorMessages.PipelineTopicUnused, {
16826
+ at: startLoc
16827
+ });
16398
16828
  }
16399
16829
  }
16400
16830
 
@@ -16674,9 +17104,10 @@ class StatementParser extends ExpressionParser {
16674
17104
  this.parseBlockBody(program, true, true, end);
16675
17105
 
16676
17106
  if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
16677
- for (var [name] of Array.from(this.scope.undefinedExports)) {
16678
- var pos = this.scope.undefinedExports.get(name);
16679
- this.raise(pos, ErrorMessages.ModuleExportUndefined, name);
17107
+ for (var [name, loc] of Array.from(this.scope.undefinedExports)) {
17108
+ this.raise(ErrorMessages.ModuleExportUndefined, {
17109
+ at: loc
17110
+ }, name);
16680
17111
  }
16681
17112
  }
16682
17113
 
@@ -16785,9 +17216,13 @@ class StatementParser extends ExpressionParser {
16785
17216
 
16786
17217
  if (context) {
16787
17218
  if (this.state.strict) {
16788
- this.raise(this.state.start, ErrorMessages.StrictFunction);
17219
+ this.raise(ErrorMessages.StrictFunction, {
17220
+ at: this.state.startLoc
17221
+ });
16789
17222
  } else if (context !== "if" && context !== "label") {
16790
- this.raise(this.state.start, ErrorMessages.SloppyFunction);
17223
+ this.raise(ErrorMessages.SloppyFunction, {
17224
+ at: this.state.startLoc
17225
+ });
16791
17226
  }
16792
17227
  }
16793
17228
 
@@ -16817,7 +17252,9 @@ class StatementParser extends ExpressionParser {
16817
17252
  kind = kind || this.state.value;
16818
17253
 
16819
17254
  if (context && kind !== "var") {
16820
- this.raise(this.state.start, ErrorMessages.UnexpectedLexicalDeclaration);
17255
+ this.raise(ErrorMessages.UnexpectedLexicalDeclaration, {
17256
+ at: this.state.startLoc
17257
+ });
16821
17258
  }
16822
17259
 
16823
17260
  return this.parseVarStatement(node, kind);
@@ -16846,7 +17283,9 @@ class StatementParser extends ExpressionParser {
16846
17283
  case 78:
16847
17284
  {
16848
17285
  if (!this.options.allowImportExportEverywhere && !topLevel) {
16849
- this.raise(this.state.start, ErrorMessages.UnexpectedImportExport);
17286
+ this.raise(ErrorMessages.UnexpectedImportExport, {
17287
+ at: this.state.startLoc
17288
+ });
16850
17289
  }
16851
17290
 
16852
17291
  this.next();
@@ -16874,7 +17313,9 @@ class StatementParser extends ExpressionParser {
16874
17313
  {
16875
17314
  if (this.isAsyncFunction()) {
16876
17315
  if (context) {
16877
- this.raise(this.state.start, ErrorMessages.AsyncFunctionInSingleStatementContext);
17316
+ this.raise(ErrorMessages.AsyncFunctionInSingleStatementContext, {
17317
+ at: this.state.startLoc
17318
+ });
16878
17319
  }
16879
17320
 
16880
17321
  this.next();
@@ -16895,7 +17336,9 @@ class StatementParser extends ExpressionParser {
16895
17336
 
16896
17337
  assertModuleNodeAllowed(node) {
16897
17338
  if (!this.options.allowImportExportEverywhere && !this.inModule) {
16898
- this.raise(node.start, SourceTypeModuleErrorMessages.ImportOutsideModule);
17339
+ this.raise(SourceTypeModuleErrorMessages.ImportOutsideModule, {
17340
+ node
17341
+ });
16899
17342
  }
16900
17343
  }
16901
17344
 
@@ -16927,10 +17370,14 @@ class StatementParser extends ExpressionParser {
16927
17370
  }
16928
17371
 
16929
17372
  if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
16930
- this.raise(this.state.start, ErrorMessages.DecoratorExportClass);
17373
+ this.raise(ErrorMessages.DecoratorExportClass, {
17374
+ at: this.state.startLoc
17375
+ });
16931
17376
  }
16932
17377
  } else if (!this.canHaveLeadingDecorator()) {
16933
- throw this.raise(this.state.start, ErrorMessages.UnexpectedLeadingDecorator);
17378
+ throw this.raise(ErrorMessages.UnexpectedLeadingDecorator, {
17379
+ at: this.state.startLoc
17380
+ });
16934
17381
  }
16935
17382
  }
16936
17383
 
@@ -17009,7 +17456,9 @@ class StatementParser extends ExpressionParser {
17009
17456
  }
17010
17457
 
17011
17458
  if (i === this.state.labels.length) {
17012
- this.raise(node.start, ErrorMessages.IllegalBreakContinue, isBreak ? "break" : "continue");
17459
+ this.raise(ErrorMessages.IllegalBreakContinue, {
17460
+ node
17461
+ }, isBreak ? "break" : "continue");
17013
17462
  }
17014
17463
  }
17015
17464
 
@@ -17040,17 +17489,17 @@ class StatementParser extends ExpressionParser {
17040
17489
  parseForStatement(node) {
17041
17490
  this.next();
17042
17491
  this.state.labels.push(loopLabel);
17043
- var awaitAt = -1;
17492
+ var awaitAt = null;
17044
17493
 
17045
17494
  if (this.isAwaitAllowed() && this.eatContextual(92)) {
17046
- awaitAt = this.state.lastTokStart;
17495
+ awaitAt = this.state.lastTokStartLoc;
17047
17496
  }
17048
17497
 
17049
17498
  this.scope.enter(SCOPE_OTHER);
17050
17499
  this.expect(10);
17051
17500
 
17052
17501
  if (this.match(13)) {
17053
- if (awaitAt > -1) {
17502
+ if (awaitAt !== null) {
17054
17503
  this.unexpected(awaitAt);
17055
17504
  }
17056
17505
 
@@ -17072,7 +17521,7 @@ class StatementParser extends ExpressionParser {
17072
17521
  return this.parseForIn(node, _init, awaitAt);
17073
17522
  }
17074
17523
 
17075
- if (awaitAt > -1) {
17524
+ if (awaitAt !== null) {
17076
17525
  this.unexpected(awaitAt);
17077
17526
  }
17078
17527
 
@@ -17086,9 +17535,15 @@ class StatementParser extends ExpressionParser {
17086
17535
 
17087
17536
  if (isForOf) {
17088
17537
  if (startsWithLet) {
17089
- this.raise(init.start, ErrorMessages.ForOfLet);
17090
- } else if (awaitAt === -1 && startsWithAsync && init.type === "Identifier") {
17091
- this.raise(init.start, ErrorMessages.ForOfAsync);
17538
+ this.raise(ErrorMessages.ForOfLet, {
17539
+ node: init
17540
+ });
17541
+ }
17542
+
17543
+ if (awaitAt === null && startsWithAsync && init.type === "Identifier") {
17544
+ this.raise(ErrorMessages.ForOfAsync, {
17545
+ node: init
17546
+ });
17092
17547
  }
17093
17548
  }
17094
17549
 
@@ -17101,7 +17556,7 @@ class StatementParser extends ExpressionParser {
17101
17556
  this.checkExpressionErrors(refExpressionErrors, true);
17102
17557
  }
17103
17558
 
17104
- if (awaitAt > -1) {
17559
+ if (awaitAt !== null) {
17105
17560
  this.unexpected(awaitAt);
17106
17561
  }
17107
17562
 
@@ -17123,7 +17578,9 @@ class StatementParser extends ExpressionParser {
17123
17578
 
17124
17579
  parseReturnStatement(node) {
17125
17580
  if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
17126
- this.raise(this.state.start, ErrorMessages.IllegalReturn);
17581
+ this.raise(ErrorMessages.IllegalReturn, {
17582
+ at: this.state.startLoc
17583
+ });
17127
17584
  }
17128
17585
 
17129
17586
  this.next();
@@ -17159,7 +17616,9 @@ class StatementParser extends ExpressionParser {
17159
17616
  cur.test = this.parseExpression();
17160
17617
  } else {
17161
17618
  if (sawDefault) {
17162
- this.raise(this.state.lastTokStart, ErrorMessages.MultipleDefaultsInSwitch);
17619
+ this.raise(ErrorMessages.MultipleDefaultsInSwitch, {
17620
+ at: this.state.lastTokStartLoc
17621
+ });
17163
17622
  }
17164
17623
 
17165
17624
  sawDefault = true;
@@ -17187,7 +17646,9 @@ class StatementParser extends ExpressionParser {
17187
17646
  this.next();
17188
17647
 
17189
17648
  if (this.hasPrecedingLineBreak()) {
17190
- this.raise(this.state.lastTokEnd, ErrorMessages.NewlineAfterThrow);
17649
+ this.raise(ErrorMessages.NewlineAfterThrow, {
17650
+ at: this.state.lastTokEndLoc
17651
+ });
17191
17652
  }
17192
17653
 
17193
17654
  node.argument = this.parseExpression();
@@ -17229,7 +17690,9 @@ class StatementParser extends ExpressionParser {
17229
17690
  node.finalizer = this.eat(63) ? this.parseBlock() : null;
17230
17691
 
17231
17692
  if (!node.handler && !node.finalizer) {
17232
- this.raise(node.start, ErrorMessages.NoCatchOrFinally);
17693
+ this.raise(ErrorMessages.NoCatchOrFinally, {
17694
+ node
17695
+ });
17233
17696
  }
17234
17697
 
17235
17698
  return this.finishNode(node, "TryStatement");
@@ -17253,7 +17716,9 @@ class StatementParser extends ExpressionParser {
17253
17716
 
17254
17717
  parseWithStatement(node) {
17255
17718
  if (this.state.strict) {
17256
- this.raise(this.state.start, ErrorMessages.StrictWith);
17719
+ this.raise(ErrorMessages.StrictWith, {
17720
+ at: this.state.startLoc
17721
+ });
17257
17722
  }
17258
17723
 
17259
17724
  this.next();
@@ -17270,7 +17735,9 @@ class StatementParser extends ExpressionParser {
17270
17735
  parseLabeledStatement(node, maybeName, expr, context) {
17271
17736
  for (var label of this.state.labels) {
17272
17737
  if (label.name === maybeName) {
17273
- this.raise(expr.start, ErrorMessages.LabelRedeclaration, maybeName);
17738
+ this.raise(ErrorMessages.LabelRedeclaration, {
17739
+ node: expr
17740
+ }, maybeName);
17274
17741
  }
17275
17742
  }
17276
17743
 
@@ -17396,15 +17863,21 @@ class StatementParser extends ExpressionParser {
17396
17863
  this.next();
17397
17864
 
17398
17865
  if (isForIn) {
17399
- if (awaitAt > -1) this.unexpected(awaitAt);
17866
+ if (awaitAt !== null) this.unexpected(awaitAt);
17400
17867
  } else {
17401
- node.await = awaitAt > -1;
17868
+ node.await = awaitAt !== null;
17402
17869
  }
17403
17870
 
17404
17871
  if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
17405
- this.raise(init.start, ErrorMessages.ForInOfLoopInitializer, isForIn ? "for-in" : "for-of");
17406
- } else if (init.type === "AssignmentPattern") {
17407
- this.raise(init.start, ErrorMessages.InvalidLhs, "for-loop");
17872
+ this.raise(ErrorMessages.ForInOfLoopInitializer, {
17873
+ node: init
17874
+ }, isForIn ? "for-in" : "for-of");
17875
+ }
17876
+
17877
+ if (init.type === "AssignmentPattern") {
17878
+ this.raise(ErrorMessages.InvalidLhs, {
17879
+ node: init
17880
+ }, "for-loop");
17408
17881
  }
17409
17882
 
17410
17883
  node.left = init;
@@ -17430,10 +17903,14 @@ class StatementParser extends ExpressionParser {
17430
17903
  } else {
17431
17904
  if (kind === "const" && !(this.match(54) || this.isContextual(97))) {
17432
17905
  if (!isTypescript) {
17433
- this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Const declarations");
17906
+ this.raise(ErrorMessages.DeclarationMissingInitializer, {
17907
+ at: this.state.lastTokEndLoc
17908
+ }, "Const declarations");
17434
17909
  }
17435
17910
  } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(54) || this.isContextual(97)))) {
17436
- this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Complex binding patterns");
17911
+ this.raise(ErrorMessages.DeclarationMissingInitializer, {
17912
+ at: this.state.lastTokEndLoc
17913
+ }, "Complex binding patterns");
17437
17914
  }
17438
17915
 
17439
17916
  decl.init = null;
@@ -17460,7 +17937,9 @@ class StatementParser extends ExpressionParser {
17460
17937
  this.initFunction(node, isAsync);
17461
17938
 
17462
17939
  if (this.match(51) && isHangingStatement) {
17463
- this.raise(this.state.start, ErrorMessages.GeneratorInSingleStatementContext);
17940
+ this.raise(ErrorMessages.GeneratorInSingleStatementContext, {
17941
+ at: this.state.startLoc
17942
+ });
17464
17943
  }
17465
17944
 
17466
17945
  node.generator = this.eat(51);
@@ -17506,7 +17985,7 @@ class StatementParser extends ExpressionParser {
17506
17985
 
17507
17986
  registerFunctionStatementId(node) {
17508
17987
  if (!node.id) return;
17509
- this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.start);
17988
+ this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.loc.start);
17510
17989
  }
17511
17990
 
17512
17991
  parseClass(node, isStatement, optionalId) {
@@ -17546,7 +18025,9 @@ class StatementParser extends ExpressionParser {
17546
18025
  while (!this.match(8)) {
17547
18026
  if (this.eat(13)) {
17548
18027
  if (decorators.length > 0) {
17549
- throw this.raise(this.state.lastTokEnd, ErrorMessages.DecoratorSemicolon);
18028
+ throw this.raise(ErrorMessages.DecoratorSemicolon, {
18029
+ at: this.state.lastTokEndLoc
18030
+ });
17550
18031
  }
17551
18032
 
17552
18033
  continue;
@@ -17568,7 +18049,9 @@ class StatementParser extends ExpressionParser {
17568
18049
  this.parseClassMember(classBody, member, state);
17569
18050
 
17570
18051
  if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
17571
- this.raise(member.start, ErrorMessages.DecoratorConstructor);
18052
+ this.raise(ErrorMessages.DecoratorConstructor, {
18053
+ node: member
18054
+ });
17572
18055
  }
17573
18056
  }
17574
18057
  });
@@ -17576,7 +18059,9 @@ class StatementParser extends ExpressionParser {
17576
18059
  this.next();
17577
18060
 
17578
18061
  if (decorators.length) {
17579
- throw this.raise(this.state.start, ErrorMessages.TrailingDecorator);
18062
+ throw this.raise(ErrorMessages.TrailingDecorator, {
18063
+ at: this.state.startLoc
18064
+ });
17580
18065
  }
17581
18066
 
17582
18067
  this.classScope.exit();
@@ -17645,7 +18130,9 @@ class StatementParser extends ExpressionParser {
17645
18130
  }
17646
18131
 
17647
18132
  if (this.isNonstaticConstructor(publicMethod)) {
17648
- this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsGenerator);
18133
+ this.raise(ErrorMessages.ConstructorIsGenerator, {
18134
+ node: publicMethod.key
18135
+ });
17649
18136
  }
17650
18137
 
17651
18138
  this.pushClassMethod(classBody, publicMethod, true, false, false, false);
@@ -17655,7 +18142,7 @@ class StatementParser extends ExpressionParser {
17655
18142
  var isContextual = tokenIsIdentifier(this.state.type) && !this.state.containsEsc;
17656
18143
  var isPrivate = this.match(130);
17657
18144
  var key = this.parseClassElementName(member);
17658
- var maybeQuestionTokenStart = this.state.start;
18145
+ var maybeQuestionTokenStartLoc = this.state.startLoc;
17659
18146
  this.parsePostMemberNameModifiers(publicMember);
17660
18147
 
17661
18148
  if (this.isClassMethod()) {
@@ -17673,11 +18160,15 @@ class StatementParser extends ExpressionParser {
17673
18160
  publicMethod.kind = "constructor";
17674
18161
 
17675
18162
  if (state.hadConstructor && !this.hasPlugin("typescript")) {
17676
- this.raise(key.start, ErrorMessages.DuplicateConstructor);
18163
+ this.raise(ErrorMessages.DuplicateConstructor, {
18164
+ node: key
18165
+ });
17677
18166
  }
17678
18167
 
17679
18168
  if (isConstructor && this.hasPlugin("typescript") && member.override) {
17680
- this.raise(key.start, ErrorMessages.OverrideOnConstructor);
18169
+ this.raise(ErrorMessages.OverrideOnConstructor, {
18170
+ node: key
18171
+ });
17681
18172
  }
17682
18173
 
17683
18174
  state.hadConstructor = true;
@@ -17696,7 +18187,7 @@ class StatementParser extends ExpressionParser {
17696
18187
  var isGenerator = this.eat(51);
17697
18188
 
17698
18189
  if (publicMember.optional) {
17699
- this.unexpected(maybeQuestionTokenStart);
18190
+ this.unexpected(maybeQuestionTokenStartLoc);
17700
18191
  }
17701
18192
 
17702
18193
  method.kind = "method";
@@ -17710,7 +18201,9 @@ class StatementParser extends ExpressionParser {
17710
18201
  this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
17711
18202
  } else {
17712
18203
  if (this.isNonstaticConstructor(publicMethod)) {
17713
- this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAsync);
18204
+ this.raise(ErrorMessages.ConstructorIsAsync, {
18205
+ node: publicMethod.key
18206
+ });
17714
18207
  }
17715
18208
 
17716
18209
  this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
@@ -17727,7 +18220,9 @@ class StatementParser extends ExpressionParser {
17727
18220
  this.pushClassPrivateMethod(classBody, privateMethod, false, false);
17728
18221
  } else {
17729
18222
  if (this.isNonstaticConstructor(publicMethod)) {
17730
- this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAccessor);
18223
+ this.raise(ErrorMessages.ConstructorIsAccessor, {
18224
+ node: publicMethod.key
18225
+ });
17731
18226
  }
17732
18227
 
17733
18228
  this.pushClassMethod(classBody, publicMethod, false, false, false, false);
@@ -17748,17 +18243,20 @@ class StatementParser extends ExpressionParser {
17748
18243
  parseClassElementName(member) {
17749
18244
  var {
17750
18245
  type,
17751
- value,
17752
- start
18246
+ value
17753
18247
  } = this.state;
17754
18248
 
17755
18249
  if ((type === 124 || type === 125) && member.static && value === "prototype") {
17756
- this.raise(start, ErrorMessages.StaticPrototype);
18250
+ this.raise(ErrorMessages.StaticPrototype, {
18251
+ at: this.state.startLoc
18252
+ });
17757
18253
  }
17758
18254
 
17759
18255
  if (type === 130) {
17760
18256
  if (value === "constructor") {
17761
- this.raise(start, ErrorMessages.ConstructorClassPrivateField);
18257
+ this.raise(ErrorMessages.ConstructorClassPrivateField, {
18258
+ at: this.state.startLoc
18259
+ });
17762
18260
  }
17763
18261
 
17764
18262
  var key = this.parsePrivateName();
@@ -17784,13 +18282,17 @@ class StatementParser extends ExpressionParser {
17784
18282
  classBody.body.push(this.finishNode(member, "StaticBlock"));
17785
18283
 
17786
18284
  if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
17787
- this.raise(member.start, ErrorMessages.DecoratorStaticBlock);
18285
+ this.raise(ErrorMessages.DecoratorStaticBlock, {
18286
+ node: member
18287
+ });
17788
18288
  }
17789
18289
  }
17790
18290
 
17791
18291
  pushClassProperty(classBody, prop) {
17792
18292
  if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
17793
- this.raise(prop.key.start, ErrorMessages.ConstructorClassField);
18293
+ this.raise(ErrorMessages.ConstructorClassField, {
18294
+ node: prop.key
18295
+ });
17794
18296
  }
17795
18297
 
17796
18298
  classBody.body.push(this.parseClassProperty(prop));
@@ -17799,7 +18301,7 @@ class StatementParser extends ExpressionParser {
17799
18301
  pushClassPrivateProperty(classBody, prop) {
17800
18302
  var node = this.parseClassPrivateProperty(prop);
17801
18303
  classBody.body.push(node);
17802
- this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.start);
18304
+ this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.loc.start);
17803
18305
  }
17804
18306
 
17805
18307
  pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
@@ -17814,7 +18316,7 @@ class StatementParser extends ExpressionParser {
17814
18316
  }
17815
18317
 
17816
18318
  declareClassPrivateMethodInScope(node, kind) {
17817
- this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.start);
18319
+ this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start);
17818
18320
  }
17819
18321
 
17820
18322
  parsePostMemberNameModifiers(methodOrProp) {}
@@ -17854,7 +18356,9 @@ class StatementParser extends ExpressionParser {
17854
18356
  if (optionalId || !isStatement) {
17855
18357
  node.id = null;
17856
18358
  } else {
17857
- this.unexpected(null, ErrorMessages.MissingClassName);
18359
+ throw this.raise(ErrorMessages.MissingClassName, {
18360
+ at: this.state.startLoc
18361
+ });
17858
18362
  }
17859
18363
  }
17860
18364
  }
@@ -17987,22 +18491,32 @@ class StatementParser extends ExpressionParser {
17987
18491
  }
17988
18492
 
17989
18493
  return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
17990
- } else if (this.match(76)) {
18494
+ }
18495
+
18496
+ if (this.match(76)) {
17991
18497
  return this.parseClass(expr, true, true);
17992
- } else if (this.match(26)) {
18498
+ }
18499
+
18500
+ if (this.match(26)) {
17993
18501
  if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
17994
- this.raise(this.state.start, ErrorMessages.DecoratorBeforeExport);
18502
+ this.raise(ErrorMessages.DecoratorBeforeExport, {
18503
+ at: this.state.startLoc
18504
+ });
17995
18505
  }
17996
18506
 
17997
18507
  this.parseDecorators(false);
17998
18508
  return this.parseClass(expr, true, true);
17999
- } else if (this.match(71) || this.match(70) || this.isLet()) {
18000
- throw this.raise(this.state.start, ErrorMessages.UnsupportedDefaultExport);
18001
- } else {
18002
- var res = this.parseMaybeAssignAllowIn();
18003
- this.semicolon();
18004
- return res;
18005
18509
  }
18510
+
18511
+ if (this.match(71) || this.match(70) || this.isLet()) {
18512
+ throw this.raise(ErrorMessages.UnsupportedDefaultExport, {
18513
+ at: this.state.startLoc
18514
+ });
18515
+ }
18516
+
18517
+ var res = this.parseMaybeAssignAllowIn();
18518
+ this.semicolon();
18519
+ return res;
18006
18520
  }
18007
18521
 
18008
18522
  parseExportDeclaration(node) {
@@ -18074,10 +18588,12 @@ class StatementParser extends ExpressionParser {
18074
18588
 
18075
18589
  if (this.hasPlugin("decorators")) {
18076
18590
  if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
18077
- this.unexpected(this.state.start, ErrorMessages.DecoratorBeforeExport);
18078
- } else {
18079
- return true;
18591
+ throw this.raise(ErrorMessages.DecoratorBeforeExport, {
18592
+ at: this.state.startLoc
18593
+ });
18080
18594
  }
18595
+
18596
+ return true;
18081
18597
  }
18082
18598
  }
18083
18599
 
@@ -18095,7 +18611,9 @@ class StatementParser extends ExpressionParser {
18095
18611
  var declaration = node.declaration;
18096
18612
 
18097
18613
  if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
18098
- this.raise(declaration.start, ErrorMessages.ExportDefaultFromAsIdentifier);
18614
+ this.raise(ErrorMessages.ExportDefaultFromAsIdentifier, {
18615
+ node: declaration
18616
+ });
18099
18617
  }
18100
18618
  }
18101
18619
  } else if (node.specifiers && node.specifiers.length) {
@@ -18112,9 +18630,11 @@ class StatementParser extends ExpressionParser {
18112
18630
  } = specifier;
18113
18631
 
18114
18632
  if (local.type !== "Identifier") {
18115
- this.raise(specifier.start, ErrorMessages.ExportBindingIsString, local.value, exportedName);
18633
+ this.raise(ErrorMessages.ExportBindingIsString, {
18634
+ node: specifier
18635
+ }, local.value, exportedName);
18116
18636
  } else {
18117
- this.checkReservedWord(local.name, local.start, true, false);
18637
+ this.checkReservedWord(local.name, local.loc.start, true, false);
18118
18638
  this.scope.checkLocalExport(local);
18119
18639
  }
18120
18640
  }
@@ -18135,7 +18655,9 @@ class StatementParser extends ExpressionParser {
18135
18655
  var currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
18136
18656
 
18137
18657
  if (currentContextDecorators.length) {
18138
- throw this.raise(node.start, ErrorMessages.UnsupportedDecoratorExport);
18658
+ throw this.raise(ErrorMessages.UnsupportedDecoratorExport, {
18659
+ node
18660
+ });
18139
18661
  }
18140
18662
  }
18141
18663
 
@@ -18163,7 +18685,9 @@ class StatementParser extends ExpressionParser {
18163
18685
 
18164
18686
  checkDuplicateExports(node, name) {
18165
18687
  if (this.exportedIdentifiers.has(name)) {
18166
- this.raise(node.start, name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, name);
18688
+ this.raise(name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, {
18689
+ node
18690
+ }, name);
18167
18691
  }
18168
18692
 
18169
18693
  this.exportedIdentifiers.add(name);
@@ -18210,7 +18734,9 @@ class StatementParser extends ExpressionParser {
18210
18734
  var surrogate = result.value.match(loneSurrogate);
18211
18735
 
18212
18736
  if (surrogate) {
18213
- this.raise(result.start, ErrorMessages.ModuleExportNameHasLoneSurrogate, surrogate[0].charCodeAt(0).toString(16));
18737
+ this.raise(ErrorMessages.ModuleExportNameHasLoneSurrogate, {
18738
+ node: result
18739
+ }, surrogate[0].charCodeAt(0).toString(16));
18214
18740
  }
18215
18741
 
18216
18742
  return result;
@@ -18275,7 +18801,9 @@ class StatementParser extends ExpressionParser {
18275
18801
  var keyName = this.state.value;
18276
18802
 
18277
18803
  if (attrNames.has(keyName)) {
18278
- this.raise(this.state.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, keyName);
18804
+ this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
18805
+ at: this.state.startLoc
18806
+ }, keyName);
18279
18807
  }
18280
18808
 
18281
18809
  attrNames.add(keyName);
@@ -18289,7 +18817,9 @@ class StatementParser extends ExpressionParser {
18289
18817
  this.expect(14);
18290
18818
 
18291
18819
  if (!this.match(125)) {
18292
- throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
18820
+ throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
18821
+ at: this.state.startLoc
18822
+ });
18293
18823
  }
18294
18824
 
18295
18825
  node.value = this.parseStringLiteral(this.state.value);
@@ -18317,18 +18847,24 @@ class StatementParser extends ExpressionParser {
18317
18847
  node.key = this.parseIdentifier(true);
18318
18848
 
18319
18849
  if (node.key.name !== "type") {
18320
- this.raise(node.key.start, ErrorMessages.ModuleAttributeDifferentFromType, node.key.name);
18850
+ this.raise(ErrorMessages.ModuleAttributeDifferentFromType, {
18851
+ node: node.key
18852
+ }, node.key.name);
18321
18853
  }
18322
18854
 
18323
18855
  if (attributes.has(node.key.name)) {
18324
- this.raise(node.key.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, node.key.name);
18856
+ this.raise(ErrorMessages.ModuleAttributesWithDuplicateKeys, {
18857
+ node: node.key
18858
+ }, node.key.name);
18325
18859
  }
18326
18860
 
18327
18861
  attributes.add(node.key.name);
18328
18862
  this.expect(14);
18329
18863
 
18330
18864
  if (!this.match(125)) {
18331
- throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
18865
+ throw this.raise(ErrorMessages.ModuleAttributeInvalidValue, {
18866
+ at: this.state.startLoc
18867
+ });
18332
18868
  }
18333
18869
 
18334
18870
  node.value = this.parseStringLiteral(this.state.value);
@@ -18384,7 +18920,9 @@ class StatementParser extends ExpressionParser {
18384
18920
  first = false;
18385
18921
  } else {
18386
18922
  if (this.eat(14)) {
18387
- throw this.raise(this.state.start, ErrorMessages.DestructureNamedImport);
18923
+ throw this.raise(ErrorMessages.DestructureNamedImport, {
18924
+ at: this.state.startLoc
18925
+ });
18388
18926
  }
18389
18927
 
18390
18928
  this.expect(12);
@@ -18409,10 +18947,12 @@ class StatementParser extends ExpressionParser {
18409
18947
  } = specifier;
18410
18948
 
18411
18949
  if (importedIsString) {
18412
- throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, imported.value);
18950
+ throw this.raise(ErrorMessages.ImportBindingIsString, {
18951
+ node: specifier
18952
+ }, imported.value);
18413
18953
  }
18414
18954
 
18415
- this.checkReservedWord(imported.name, specifier.start, true, true);
18955
+ this.checkReservedWord(imported.name, specifier.loc.start, true, true);
18416
18956
 
18417
18957
  if (!specifier.local) {
18418
18958
  specifier.local = cloneIdentifier(imported);
@@ -21232,7 +21772,7 @@ function safeYamlParse(value) {
21232
21772
  }
21233
21773
 
21234
21774
  var fieldsToKeepInMenu = ["menuId", "title", "icon", "titleDataSource", "defaultCollapsed", "defaultCollapsedBreakpoint", "link", "type", "injectMenuGroupId", "dynamicItems", "itemsResolve"];
21235
- var fieldsToKeepInMenuItem = ["text", "to", "target", "icon", "exact", "key", "activeIncludes", "activeExcludes", "activeMatchSearch", "type", "sort", "defaultExpanded", "if", "groupId"];
21775
+ var fieldsToKeepInMenuItem = ["text", "to", "href", "target", "icon", "exact", "key", "activeIncludes", "activeExcludes", "activeMatchSearch", "type", "sort", "defaultExpanded", "if", "groupId"];
21236
21776
  function normalizeMenu(node) {
21237
21777
  return _objectSpread(_objectSpread({}, keep(node, fieldsToKeepInMenu)), {}, {
21238
21778
  items: keepItems(node.items, fieldsToKeepInMenuItem)