@diagonal-hq/cli 0.39.1 → 0.40.0

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.
@@ -398,9 +398,10 @@ var StandardErrors = {
398
398
  EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
399
399
  ExportBindingIsString: ({
400
400
  localName,
401
- exportName
401
+ exportName,
402
+ typeModifierIn
402
403
  }) => `A string literal cannot be used as an exported binding without \`from\`.
403
- - Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
404
+ - Did you mean \`export ${typeModifierIn === "declaration" ? "type " : ""}{ ${typeModifierIn === "specifier" ? "type " : ""}'${localName}' as '${exportName}' } from 'some-module'\`?`,
404
405
  ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
405
406
  FilteredNamespaceDuplicateName: ({
406
407
  name
@@ -3209,7 +3210,6 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
3209
3210
  }
3210
3211
  this.expect(13);
3211
3212
  const state = this.state.clone();
3212
- const originalNoArrowAt = this.state.noArrowAt;
3213
3213
  const node = this.startNodeAt(startLoc);
3214
3214
  let {
3215
3215
  consequent,
@@ -3219,12 +3219,10 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
3219
3219
  let valid = result[0];
3220
3220
  const invalid = result[1];
3221
3221
  if (failed || invalid.length > 0) {
3222
- const noArrowAt = [...originalNoArrowAt];
3223
3222
  if (invalid.length > 0) {
3224
3223
  this.state = state;
3225
- this.state.noArrowAt = noArrowAt;
3226
3224
  for (let i = 0; i < invalid.length; i++) {
3227
- noArrowAt.push(invalid[i].start);
3225
+ this.noArrowAt.add(this.offsetToSourcePos(invalid[i].start));
3228
3226
  }
3229
3227
  ({
3230
3228
  consequent,
@@ -3237,15 +3235,13 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
3237
3235
  }
3238
3236
  if (failed && valid.length === 1) {
3239
3237
  this.state = state;
3240
- noArrowAt.push(valid[0].start);
3241
- this.state.noArrowAt = noArrowAt;
3238
+ this.noArrowAt.add(this.offsetToSourcePos(valid[0].start));
3242
3239
  ({
3243
3240
  consequent
3244
3241
  } = this.tryParseConditionalConsequent());
3245
3242
  }
3246
3243
  }
3247
3244
  this.getArrowLikeExpressions(consequent, true);
3248
- this.state.noArrowAt = originalNoArrowAt;
3249
3245
  this.expect(10);
3250
3246
  node.test = expr;
3251
3247
  node.consequent = consequent;
@@ -3730,8 +3726,8 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
3730
3726
  }
3731
3727
  return super.parseAsyncArrowFromCallExpression(node, call);
3732
3728
  }
3733
- shouldParseAsyncArrow() {
3734
- return this.match(10) || super.shouldParseAsyncArrow();
3729
+ parseAsyncArrowHead(startLoc) {
3730
+ return this.match(10) ? this.startNodeAt(startLoc) : super.parseAsyncArrowHead(startLoc);
3735
3731
  }
3736
3732
  parseMaybeAssign(refExpressionErrors, isParenItem) {
3737
3733
  let state = null;
@@ -3829,10 +3825,10 @@ var flow = (superClass) => class FlowParserMixin extends superClass {
3829
3825
  super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
3830
3826
  }
3831
3827
  parseParenAndDistinguishExpression(canStartArrow) {
3832
- return super.parseParenAndDistinguishExpression(canStartArrow && !this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)));
3828
+ return super.parseParenAndDistinguishExpression(canStartArrow && !this.noArrowAt.has(this.state.start));
3833
3829
  }
3834
3830
  parseSubscripts(base, startLoc, noCalls) {
3835
- if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.includes(startLoc.index)) {
3831
+ if (base.type === "Identifier" && base.name === "async" && this.noArrowAt.has(this.offsetToSourcePos(startLoc.index))) {
3836
3832
  this.next();
3837
3833
  const node = this.startNodeAt(startLoc);
3838
3834
  node.callee = base;
@@ -5084,6 +5080,7 @@ var TypeScriptScopeHandler = class extends ScopeHandler {
5084
5080
  return false;
5085
5081
  }
5086
5082
  declareName(name, bindingType, loc) {
5083
+ const scope2 = this.currentScope();
5087
5084
  if (bindingType & 4096) {
5088
5085
  if (this.hasImport(name, true)) {
5089
5086
  this.parser.raise(Errors.VarRedeclaration, loc, {
@@ -5091,9 +5088,9 @@ var TypeScriptScopeHandler = class extends ScopeHandler {
5091
5088
  });
5092
5089
  }
5093
5090
  this.importsStack[this.importsStack.length - 1].add(name);
5091
+ this.maybeExportDefined(scope2, name);
5094
5092
  return;
5095
5093
  }
5096
- const scope2 = this.currentScope();
5097
5094
  let type = scope2.tsNames.get(name) || 0;
5098
5095
  if (bindingType & 1024) {
5099
5096
  this.maybeExportDefined(scope2, name);
@@ -5160,6 +5157,7 @@ var TypeScriptScopeHandler = class extends ScopeHandler {
5160
5157
  var BaseParser = class {
5161
5158
  sawUnambiguousESM = false;
5162
5159
  ambiguousScriptDifferentAst = false;
5160
+ noArrowAt = /* @__PURE__ */ new Set();
5163
5161
  sourceToOffsetPos(sourcePos) {
5164
5162
  return sourcePos + this.startIndex;
5165
5163
  }
@@ -5374,7 +5372,7 @@ var CommentsParser = class extends BaseParser {
5374
5372
  }
5375
5373
  };
5376
5374
  var State = class _State {
5377
- flags = 2048;
5375
+ flags = 1024;
5378
5376
  get strict() {
5379
5377
  return (this.flags & 1) > 0;
5380
5378
  }
@@ -5401,8 +5399,8 @@ var State = class _State {
5401
5399
  this.startLoc = this.endLoc = new Position(startLine, startColumn, startIndex);
5402
5400
  }
5403
5401
  errors = [];
5404
- noArrowAt = [];
5405
5402
  noArrowParamsConversionAt = [];
5403
+ tsArrowReturnTypeRestrictionAt = -1;
5406
5404
  regExpAllowedAt = -1;
5407
5405
  get canStartArrow() {
5408
5406
  return (this.flags & 2) > 0;
@@ -5453,27 +5451,20 @@ var State = class _State {
5453
5451
  if (v) this.flags |= 128;
5454
5452
  else this.flags &= -129;
5455
5453
  }
5456
- get inConditionalConsequent() {
5454
+ get inHackPipelineBody() {
5457
5455
  return (this.flags & 256) > 0;
5458
5456
  }
5459
- set inConditionalConsequent(v) {
5457
+ set inHackPipelineBody(v) {
5460
5458
  if (v) this.flags |= 256;
5461
5459
  else this.flags &= -257;
5462
5460
  }
5463
- get inHackPipelineBody() {
5461
+ get seenTopicReference() {
5464
5462
  return (this.flags & 512) > 0;
5465
5463
  }
5466
- set inHackPipelineBody(v) {
5464
+ set seenTopicReference(v) {
5467
5465
  if (v) this.flags |= 512;
5468
5466
  else this.flags &= -513;
5469
5467
  }
5470
- get seenTopicReference() {
5471
- return (this.flags & 1024) > 0;
5472
- }
5473
- set seenTopicReference(v) {
5474
- if (v) this.flags |= 1024;
5475
- else this.flags &= -1025;
5476
- }
5477
5468
  labels = [];
5478
5469
  commentsLen = 0;
5479
5470
  commentStack = [];
@@ -5486,27 +5477,41 @@ var State = class _State {
5486
5477
  lastTokStartLoc = null;
5487
5478
  context = [types.brace];
5488
5479
  get canStartJSXElement() {
5489
- return (this.flags & 2048) > 0;
5480
+ return (this.flags & 1024) > 0;
5490
5481
  }
5491
5482
  set canStartJSXElement(v) {
5483
+ if (v) this.flags |= 1024;
5484
+ else this.flags &= -1025;
5485
+ }
5486
+ get containsEsc() {
5487
+ return (this.flags & 2048) > 0;
5488
+ }
5489
+ set containsEsc(v) {
5492
5490
  if (v) this.flags |= 2048;
5493
5491
  else this.flags &= -2049;
5494
5492
  }
5495
- get containsEsc() {
5493
+ firstInvalidTemplateEscapePos = null;
5494
+ get hasTopLevelAwait() {
5496
5495
  return (this.flags & 4096) > 0;
5497
5496
  }
5498
- set containsEsc(v) {
5497
+ set hasTopLevelAwait(v) {
5499
5498
  if (v) this.flags |= 4096;
5500
5499
  else this.flags &= -4097;
5501
5500
  }
5502
- firstInvalidTemplateEscapePos = null;
5503
- get hasTopLevelAwait() {
5501
+ get tsArrowReturnTypeAllowed() {
5504
5502
  return (this.flags & 8192) > 0;
5505
5503
  }
5506
- set hasTopLevelAwait(v) {
5504
+ set tsArrowReturnTypeAllowed(v) {
5507
5505
  if (v) this.flags |= 8192;
5508
5506
  else this.flags &= -8193;
5509
5507
  }
5508
+ get tsGenericArrowParams() {
5509
+ return (this.flags & 16384) > 0;
5510
+ }
5511
+ set tsGenericArrowParams(v) {
5512
+ if (v) this.flags |= 16384;
5513
+ else this.flags &= -16385;
5514
+ }
5510
5515
  strictErrors = /* @__PURE__ */ new Map();
5511
5516
  tokensLength = 0;
5512
5517
  curPosition() {
@@ -5521,8 +5526,8 @@ var State = class _State {
5521
5526
  state.startLoc = this.startLoc;
5522
5527
  state.endLoc = this.endLoc;
5523
5528
  state.errors = this.errors.slice();
5524
- state.noArrowAt = this.noArrowAt.slice();
5525
5529
  state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
5530
+ state.tsArrowReturnTypeRestrictionAt = this.tsArrowReturnTypeRestrictionAt;
5526
5531
  state.regExpAllowedAt = this.regExpAllowedAt;
5527
5532
  state.labels = this.labels.slice();
5528
5533
  state.commentsLen = this.commentsLen;
@@ -5805,12 +5810,11 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
5805
5810
  if (code2 !== null && code2 > 1114111) {
5806
5811
  if (throwOnInvalid) {
5807
5812
  errors.invalidCodePoint(pos, lineStart, curLine);
5808
- } else {
5809
- return {
5810
- code: null,
5811
- pos
5812
- };
5813
5813
  }
5814
+ return {
5815
+ code: null,
5816
+ pos
5817
+ };
5814
5818
  }
5815
5819
  } else {
5816
5820
  ({
@@ -5838,6 +5842,30 @@ var Token = class {
5838
5842
  }
5839
5843
  };
5840
5844
  var locDataCache;
5845
+ var asciiIdentifierChar = new Uint8Array(128);
5846
+ for (let i = 0; i < 128; i++) {
5847
+ asciiIdentifierChar[i] = isIdentifierChar(i) ? 1 : 0;
5848
+ }
5849
+ var keywordBuckets = [];
5850
+ var maxKeywordLength = 0;
5851
+ keywords$1.forEach((type, word) => {
5852
+ const index3 = word.length << 7 | word.charCodeAt(0);
5853
+ (keywordBuckets[index3] ??= []).push(word, type);
5854
+ if (word.length > maxKeywordLength) maxKeywordLength = word.length;
5855
+ });
5856
+ function lookupKeyword(word, firstCode) {
5857
+ const {
5858
+ length
5859
+ } = word;
5860
+ if (length > maxKeywordLength || firstCode >= 128) return void 0;
5861
+ const bucket = keywordBuckets[length << 7 | firstCode];
5862
+ if (bucket !== void 0) {
5863
+ for (let i = 0; i < bucket.length; i += 2) {
5864
+ if (bucket[i] === word) return bucket[i + 1];
5865
+ }
5866
+ }
5867
+ return void 0;
5868
+ }
5841
5869
  var Tokenizer = class extends CommentsParser {
5842
5870
  isLookahead;
5843
5871
  tokens = [];
@@ -6022,29 +6050,36 @@ var Tokenizer = class extends CommentsParser {
6022
6050
  const spaceStart = this.state.pos;
6023
6051
  const attachComment = (this.optionFlags & 8192) > 0;
6024
6052
  let comments;
6025
- loop: while (this.state.pos < this.length) {
6026
- const ch = this.input.charCodeAt(this.state.pos);
6053
+ const {
6054
+ input,
6055
+ length
6056
+ } = this;
6057
+ let pos = spaceStart;
6058
+ loop: while (pos < length) {
6059
+ const ch = input.charCodeAt(pos);
6027
6060
  switch (ch) {
6028
6061
  case 32:
6029
6062
  case 160:
6030
6063
  case 9:
6031
- ++this.state.pos;
6064
+ ++pos;
6032
6065
  break;
6033
6066
  case 13:
6034
- if (this.input.charCodeAt(this.state.pos + 1) === 10) {
6035
- ++this.state.pos;
6067
+ if (input.charCodeAt(pos + 1) === 10) {
6068
+ ++pos;
6036
6069
  }
6037
6070
  case 10:
6038
6071
  case 8232:
6039
6072
  case 8233:
6040
- ++this.state.pos;
6073
+ ++pos;
6041
6074
  ++this.state.curLine;
6042
- this.state.lineStart = this.state.pos;
6075
+ this.state.lineStart = pos;
6043
6076
  break;
6044
6077
  case 47:
6045
- switch (this.input.charCodeAt(this.state.pos + 1)) {
6078
+ switch (input.charCodeAt(pos + 1)) {
6046
6079
  case 42: {
6080
+ this.state.pos = pos;
6047
6081
  const comment = this.skipBlockComment("*/");
6082
+ pos = this.state.pos;
6048
6083
  if (comment !== void 0) {
6049
6084
  this.addComment(comment);
6050
6085
  if (attachComment) {
@@ -6054,7 +6089,9 @@ var Tokenizer = class extends CommentsParser {
6054
6089
  break;
6055
6090
  }
6056
6091
  case 47: {
6092
+ this.state.pos = pos;
6057
6093
  const comment = this.skipLineComment(2);
6094
+ pos = this.state.pos;
6058
6095
  if (comment !== void 0) {
6059
6096
  this.addComment(comment);
6060
6097
  if (attachComment) {
@@ -6069,11 +6106,12 @@ var Tokenizer = class extends CommentsParser {
6069
6106
  break;
6070
6107
  default:
6071
6108
  if (isWhitespace(ch)) {
6072
- ++this.state.pos;
6109
+ ++pos;
6073
6110
  } else if (ch === 45 && !this.inModule && this.optionFlags & 16384) {
6074
- const pos = this.state.pos;
6075
- if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
6111
+ if (input.charCodeAt(pos + 1) === 45 && input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) {
6112
+ this.state.pos = pos;
6076
6113
  const comment = this.skipLineComment(3);
6114
+ pos = this.state.pos;
6077
6115
  if (comment !== void 0) {
6078
6116
  this.addComment(comment);
6079
6117
  if (attachComment) {
@@ -6084,9 +6122,10 @@ var Tokenizer = class extends CommentsParser {
6084
6122
  break loop;
6085
6123
  }
6086
6124
  } else if (ch === 60 && !this.inModule && this.optionFlags & 16384) {
6087
- const pos = this.state.pos;
6088
- if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) {
6125
+ if (input.charCodeAt(pos + 1) === 33 && input.charCodeAt(pos + 2) === 45 && input.charCodeAt(pos + 3) === 45) {
6126
+ this.state.pos = pos;
6089
6127
  const comment = this.skipLineComment(4);
6128
+ pos = this.state.pos;
6090
6129
  if (comment !== void 0) {
6091
6130
  this.addComment(comment);
6092
6131
  if (attachComment) {
@@ -6101,6 +6140,7 @@ var Tokenizer = class extends CommentsParser {
6101
6140
  }
6102
6141
  }
6103
6142
  }
6143
+ this.state.pos = pos;
6104
6144
  if (comments?.length) {
6105
6145
  const end = this.state.pos;
6106
6146
  const commentWhitespace = {
@@ -6706,22 +6746,32 @@ var Tokenizer = class extends CommentsParser {
6706
6746
  this.state.containsEsc = false;
6707
6747
  let word = "";
6708
6748
  const start = this.state.pos;
6709
- let chunkStart = this.state.pos;
6749
+ let chunkStart = start;
6750
+ const {
6751
+ input,
6752
+ length
6753
+ } = this;
6754
+ let pos = start;
6710
6755
  if (firstCode !== void 0) {
6711
- this.state.pos += firstCode <= 65535 ? 1 : 2;
6756
+ pos += firstCode <= 65535 ? 1 : 2;
6712
6757
  }
6713
- while (this.state.pos < this.length) {
6714
- const ch = this.codePointAtPos(this.state.pos);
6715
- if (isIdentifierChar(ch)) {
6716
- this.state.pos += ch <= 65535 ? 1 : 2;
6717
- } else if (ch === 92) {
6758
+ while (pos < length) {
6759
+ let ch = input.charCodeAt(pos);
6760
+ if (ch < 128) {
6761
+ if (asciiIdentifierChar[ch] === 1) {
6762
+ ++pos;
6763
+ continue;
6764
+ }
6765
+ if (ch !== 92) break;
6718
6766
  this.state.containsEsc = true;
6719
- word += this.input.slice(chunkStart, this.state.pos);
6767
+ word += input.slice(chunkStart, pos);
6768
+ this.state.pos = pos;
6720
6769
  const escStart = this.state.curPosition();
6721
- const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
6722
- if (this.input.charCodeAt(++this.state.pos) !== 117) {
6770
+ const identifierCheck = pos === start ? isIdentifierStart : isIdentifierChar;
6771
+ if (input.charCodeAt(++this.state.pos) !== 117) {
6723
6772
  this.raise(Errors.MissingUnicodeEscape, this.state.curPosition());
6724
6773
  chunkStart = this.state.pos - 1;
6774
+ pos = this.state.pos;
6725
6775
  continue;
6726
6776
  }
6727
6777
  ++this.state.pos;
@@ -6732,16 +6782,27 @@ var Tokenizer = class extends CommentsParser {
6732
6782
  }
6733
6783
  word += String.fromCodePoint(esc);
6734
6784
  }
6735
- chunkStart = this.state.pos;
6785
+ chunkStart = pos = this.state.pos;
6736
6786
  } else {
6737
- break;
6787
+ if ((ch & 64512) === 55296 && pos + 1 < length) {
6788
+ const trail = input.charCodeAt(pos + 1);
6789
+ if ((trail & 64512) === 56320) {
6790
+ ch = 65536 + ((ch & 1023) << 10) + (trail & 1023);
6791
+ }
6792
+ }
6793
+ if (isIdentifierChar(ch)) {
6794
+ pos += ch <= 65535 ? 1 : 2;
6795
+ } else {
6796
+ break;
6797
+ }
6738
6798
  }
6739
6799
  }
6740
- return word + this.input.slice(chunkStart, this.state.pos);
6800
+ this.state.pos = pos;
6801
+ return word + input.slice(chunkStart, pos);
6741
6802
  }
6742
6803
  readWord(firstCode) {
6743
6804
  const word = this.readWord1(firstCode);
6744
- const type = keywords$1.get(word);
6805
+ const type = lookupKeyword(word, firstCode === void 0 ? word.charCodeAt(0) : firstCode);
6745
6806
  if (type !== void 0) {
6746
6807
  this.finishToken(type, tokenLabelName(type));
6747
6808
  } else {
@@ -7939,10 +8000,14 @@ var ExpressionParser = class extends LValParser {
7939
8000
  return expr;
7940
8001
  }
7941
8002
  parseExpression(disallowIn, refExpressionErrors) {
7942
- if (disallowIn) {
7943
- return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
8003
+ if (disallowIn ? this.enterDisallowIn() : this.enterAllowIn()) {
8004
+ try {
8005
+ return this.parseExpressionBase(refExpressionErrors);
8006
+ } finally {
8007
+ this.prodParam.exit();
8008
+ }
7944
8009
  }
7945
- return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
8010
+ return this.parseExpressionBase(refExpressionErrors);
7946
8011
  }
7947
8012
  parseExpressionBase(refExpressionErrors) {
7948
8013
  const startLoc = this.state.startLoc;
@@ -7959,10 +8024,24 @@ var ExpressionParser = class extends LValParser {
7959
8024
  return expr;
7960
8025
  }
7961
8026
  parseMaybeAssignDisallowIn(refExpressionErrors) {
7962
- return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors));
8027
+ if (this.enterDisallowIn()) {
8028
+ try {
8029
+ return this.parseMaybeAssign(refExpressionErrors);
8030
+ } finally {
8031
+ this.prodParam.exit();
8032
+ }
8033
+ }
8034
+ return this.parseMaybeAssign(refExpressionErrors);
7963
8035
  }
7964
8036
  parseMaybeAssignAllowIn(refExpressionErrors, isParenItem) {
7965
- return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, isParenItem));
8037
+ if (this.enterAllowIn()) {
8038
+ try {
8039
+ return this.parseMaybeAssign(refExpressionErrors, isParenItem);
8040
+ } finally {
8041
+ this.prodParam.exit();
8042
+ }
8043
+ }
8044
+ return this.parseMaybeAssign(refExpressionErrors, isParenItem);
7966
8045
  }
7967
8046
  setOptionalParametersError(refExpressionErrors) {
7968
8047
  refExpressionErrors.optionalParametersLoc = this.state.startLoc;
@@ -8070,7 +8149,6 @@ var ExpressionParser = class extends LValParser {
8070
8149
  if (this.shouldExitDescending(expr)) {
8071
8150
  return expr;
8072
8151
  }
8073
- this.state.canStartArrow = false;
8074
8152
  return this.parseExprOp(expr, startLoc, -1);
8075
8153
  }
8076
8154
  isEscapedKeywordOperatorAfterLineBreak() {
@@ -8137,6 +8215,7 @@ var ExpressionParser = class extends LValParser {
8137
8215
  }
8138
8216
  parseExprOpBaseRightExpr(op, prec) {
8139
8217
  const startLoc = this.state.startLoc;
8218
+ this.state.canStartArrow = false;
8140
8219
  return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec);
8141
8220
  }
8142
8221
  parseHackPipeBody() {
@@ -8169,9 +8248,9 @@ var ExpressionParser = class extends LValParser {
8169
8248
  if (!sawUnary) this.checkExponentialAfterUnary(expr2);
8170
8249
  return expr2;
8171
8250
  }
8172
- const update = this.match(30);
8173
- const node = this.startNode();
8174
8251
  if (tokenIsPrefix(this.state.type)) {
8252
+ const update = this.match(30);
8253
+ const node = this.startNode();
8175
8254
  node.operator = this.state.value;
8176
8255
  node.prefix = true;
8177
8256
  this.state.canStartArrow = false;
@@ -8196,8 +8275,11 @@ var ExpressionParser = class extends LValParser {
8196
8275
  }
8197
8276
  return this.finishNode(node, "UnaryExpression");
8198
8277
  }
8278
+ const result = this.finishNode(node, "UpdateExpression");
8279
+ this.checkLVal(result.argument, result);
8280
+ return result;
8199
8281
  }
8200
- const expr = this.parseUpdate(node, update, refExpressionErrors);
8282
+ const expr = this.parseUpdate(refExpressionErrors);
8201
8283
  if (isAwait) {
8202
8284
  const {
8203
8285
  type
@@ -8210,22 +8292,17 @@ var ExpressionParser = class extends LValParser {
8210
8292
  }
8211
8293
  return expr;
8212
8294
  }
8213
- parseUpdate(node, update, refExpressionErrors) {
8214
- if (update) {
8215
- const result = this.finishNode(node, "UpdateExpression");
8216
- this.checkLVal(result.argument, result);
8217
- return result;
8218
- }
8295
+ parseUpdate(refExpressionErrors) {
8219
8296
  const startLoc = this.state.startLoc;
8220
8297
  let expr = this.parseExprSubscripts(refExpressionErrors);
8221
8298
  if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
8222
8299
  while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) {
8223
- const node2 = this.startNodeAt(startLoc);
8224
- node2.operator = this.state.value;
8225
- node2.prefix = false;
8226
- node2.argument = expr;
8300
+ const node = this.startNodeAt(startLoc);
8301
+ node.operator = this.state.value;
8302
+ node.prefix = false;
8303
+ node.argument = expr;
8227
8304
  this.next();
8228
- this.checkLVal(expr, expr = this.finishNode(node2, "UpdateExpression"));
8305
+ this.checkLVal(expr, expr = this.finishNode(node, "UpdateExpression"));
8229
8306
  }
8230
8307
  return expr;
8231
8308
  }
@@ -8357,20 +8434,25 @@ var ExpressionParser = class extends LValParser {
8357
8434
  } else {
8358
8435
  node.arguments = this.parseCallExpressionArguments(base.type !== "Super", node, refExpressionErrors);
8359
8436
  }
8360
- let finishedNode = this.finishCallExpression(node, optionalChainMember);
8361
- if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
8362
- state.stop = true;
8363
- this.checkDestructuringPrivate(refExpressionErrors);
8364
- this.expressionScope.validateAsPattern();
8365
- this.expressionScope.exit();
8366
- finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
8367
- } else {
8368
- if (maybeAsyncArrow) {
8369
- this.checkExpressionErrors(refExpressionErrors, true);
8437
+ const finishedNode = this.finishCallExpression(node, optionalChainMember);
8438
+ if (maybeAsyncArrow && !optional) {
8439
+ const errorsLength = this.state.errors.length;
8440
+ const asyncArrowHead = this.parseAsyncArrowHead(startLoc);
8441
+ if (asyncArrowHead) {
8442
+ const returnTypeErrors = this.state.errors.length > errorsLength ? this.state.errors.splice(errorsLength) : void 0;
8443
+ state.stop = true;
8444
+ this.checkDestructuringPrivate(refExpressionErrors);
8445
+ this.expressionScope.validateAsPattern();
8370
8446
  this.expressionScope.exit();
8447
+ if (returnTypeErrors) this.state.errors.push(...returnTypeErrors);
8448
+ return this.parseAsyncArrowFromCallExpression(asyncArrowHead, finishedNode);
8371
8449
  }
8372
- this.toReferencedList(node.arguments);
8373
8450
  }
8451
+ if (maybeAsyncArrow) {
8452
+ this.checkExpressionErrors(refExpressionErrors, true);
8453
+ this.expressionScope.exit();
8454
+ }
8455
+ this.toReferencedList(node.arguments);
8374
8456
  return finishedNode;
8375
8457
  }
8376
8458
  parseTaggedTemplateExpression(base, startLoc, state) {
@@ -8419,8 +8501,8 @@ var ExpressionParser = class extends LValParser {
8419
8501
  }
8420
8502
  return elts;
8421
8503
  }
8422
- shouldParseAsyncArrow() {
8423
- return this.match(15) && !this.canInsertSemicolon();
8504
+ parseAsyncArrowHead(startLoc) {
8505
+ return this.match(15) && !this.canInsertSemicolon() ? this.startNodeAt(startLoc) : void 0;
8424
8506
  }
8425
8507
  parseAsyncArrowFromCallExpression(node, call) {
8426
8508
  this.resetPreviousNodeTrailingComments(call);
@@ -8660,9 +8742,11 @@ var ExpressionParser = class extends LValParser {
8660
8742
  const oldLabels = this.state.labels;
8661
8743
  this.state.labels = [];
8662
8744
  if (isAsync) {
8745
+ this.expressionScope.enter(sharedExpressionScope);
8663
8746
  this.prodParam.enter(2);
8664
8747
  node.body = this.parseBlock();
8665
8748
  this.prodParam.exit();
8749
+ this.expressionScope.exit();
8666
8750
  } else {
8667
8751
  node.body = this.parseBlock();
8668
8752
  }
@@ -8720,7 +8804,7 @@ var ExpressionParser = class extends LValParser {
8720
8804
  parseImportMetaPropertyOrPhaseCallOrSyncCall(node) {
8721
8805
  this.next();
8722
8806
  if (this.isContextual(102) || this.isContextual(94)) {
8723
- const isSource = this.isContextual(102);
8807
+ const isSource = this.match(102);
8724
8808
  this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
8725
8809
  this.next();
8726
8810
  node.phase = isSource ? "source" : "defer";
@@ -8821,8 +8905,8 @@ var ExpressionParser = class extends LValParser {
8821
8905
  }
8822
8906
  const innerEndLoc = this.state.lastTokEndLoc;
8823
8907
  this.expect(7);
8824
- let arrowNode = this.startNodeAt(startLoc);
8825
- if (canStartArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) {
8908
+ let arrowNode;
8909
+ if (canStartArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(this.startNodeAt(startLoc)))) {
8826
8910
  this.checkDestructuringPrivate(refExpressionErrors);
8827
8911
  this.expressionScope.validateAsPattern();
8828
8912
  this.expressionScope.exit();
@@ -8988,22 +9072,23 @@ var ExpressionParser = class extends LValParser {
8988
9072
  }
8989
9073
  parsePropertyDefinition(refExpressionErrors) {
8990
9074
  const decorators = [];
9075
+ const decoratorsStartLoc = this.state.startLoc;
8991
9076
  if (this.match(22)) {
8992
9077
  if (this.hasPlugin("decorators")) {
8993
- this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc);
9078
+ this.raise(Errors.UnsupportedPropertyDecorator, decoratorsStartLoc);
8994
9079
  }
8995
9080
  while (this.match(22)) {
8996
9081
  decorators.push(this.parseDecorator());
8997
9082
  }
8998
9083
  }
8999
- const prop = this.startNode();
9000
- let isAsync = false;
9001
- let isAccessor2 = false;
9002
- let startLoc;
9003
9084
  if (this.match(17)) {
9004
9085
  if (decorators.length) this.unexpected();
9005
9086
  return this.parseSpread();
9006
9087
  }
9088
+ const prop = this.startNodeAt(decoratorsStartLoc);
9089
+ let isAsync = false;
9090
+ let isAccessor2 = false;
9091
+ let startLoc;
9007
9092
  if (decorators.length) {
9008
9093
  prop.decorators = decorators;
9009
9094
  }
@@ -9328,6 +9413,7 @@ var ExpressionParser = class extends LValParser {
9328
9413
  this.replaceToken(131);
9329
9414
  }
9330
9415
  } else {
9416
+ this.setLoc(this.state.startLoc);
9331
9417
  this.checkReservedWord(name, this.sourceToOffsetPos(start), tokenIsKeyword2, false);
9332
9418
  }
9333
9419
  this.next();
@@ -9439,7 +9525,7 @@ var ExpressionParser = class extends LValParser {
9439
9525
  return this.finishNode(node, "YieldExpression");
9440
9526
  }
9441
9527
  parseImportCall(node) {
9442
- this.next();
9528
+ this.expect(6);
9443
9529
  const args = this.parseCallExpressionArguments();
9444
9530
  if (args.length === 0 || args.length > 2) {
9445
9531
  this.raise(Errors.ImportCallArity, node, node);
@@ -9466,32 +9552,24 @@ var ExpressionParser = class extends LValParser {
9466
9552
  this.state.seenTopicReference = oldSeenTopicReference;
9467
9553
  }
9468
9554
  }
9469
- allowInAnd(callback) {
9555
+ enterAllowIn() {
9470
9556
  const flags = this.prodParam.currentFlags();
9471
9557
  const prodParamToSet = (8 | 16) & ~flags;
9472
9558
  if (prodParamToSet) {
9473
9559
  this.prodParam.enter(flags | 8 | 16);
9474
- try {
9475
- return callback();
9476
- } finally {
9477
- this.prodParam.exit();
9478
- }
9560
+ return true;
9479
9561
  }
9480
- return callback();
9562
+ return false;
9481
9563
  }
9482
- disallowInAnd(callback) {
9564
+ enterDisallowIn() {
9483
9565
  const flags = this.prodParam.currentFlags();
9484
9566
  const prodParamToClear = 8 & flags;
9485
9567
  const prodParamToSet = 16 & ~flags;
9486
9568
  if (prodParamToClear || prodParamToSet) {
9487
9569
  this.prodParam.enter(flags & -9 | 16);
9488
- try {
9489
- return callback();
9490
- } finally {
9491
- this.prodParam.exit();
9492
- }
9570
+ return true;
9493
9571
  }
9494
- return callback();
9572
+ return false;
9495
9573
  }
9496
9574
  registerTopicReference() {
9497
9575
  this.state.seenTopicReference = true;
@@ -10465,7 +10543,7 @@ var StatementParser = class extends ExpressionParser {
10465
10543
  return this.finishNode(node, isStatement5 ? "ClassDeclaration" : "ClassExpression");
10466
10544
  }
10467
10545
  isClassProperty() {
10468
- return this.match(25) || this.match(9) || this.match(4);
10546
+ return this.match(25) || this.match(9) || this.match(4) || this.match(22) && this.hasPrecedingLineBreak();
10469
10547
  }
10470
10548
  isClassMethod() {
10471
10549
  return this.match(6);
@@ -11054,7 +11132,8 @@ var StatementParser = class extends ExpressionParser {
11054
11132
  if (local.type !== "Identifier") {
11055
11133
  this.raise(Errors.ExportBindingIsString, specifier, {
11056
11134
  localName: local.value,
11057
- exportName
11135
+ exportName,
11136
+ typeModifierIn: node.exportKind === "type" ? "declaration" : specifier.exportKind === "type" ? "specifier" : void 0
11058
11137
  });
11059
11138
  } else {
11060
11139
  this.checkReservedWord(local.name, local.start, true, false);
@@ -11621,6 +11700,39 @@ function tsIsTypeCast(node) {
11621
11700
  return false;
11622
11701
  }
11623
11702
  }
11703
+ function tsIsInvalidArrowParamsError(error, returnTypeStart) {
11704
+ if (error.pos >= returnTypeStart) return false;
11705
+ switch (error.reasonCode) {
11706
+ case "AwaitBindingIdentifier":
11707
+ case "AwaitExpressionFormalParameter":
11708
+ case "IllegalLanguageModeDirective":
11709
+ case "ParamDupe":
11710
+ case "StrictEvalArgumentsBinding":
11711
+ case "VarRedeclaration":
11712
+ case "YieldInParameter":
11713
+ return false;
11714
+ default:
11715
+ return true;
11716
+ }
11717
+ }
11718
+ function tsHasUnambiguousArrowParams(params) {
11719
+ if (!params?.length) return true;
11720
+ let first = params[0];
11721
+ if (first?.type === "AssignmentPattern" || first?.type === "AssignmentExpression") {
11722
+ first = first.left;
11723
+ }
11724
+ switch (first?.type) {
11725
+ case "RestElement":
11726
+ case "SpreadElement":
11727
+ return true;
11728
+ case "TSTypeCastExpression":
11729
+ return first.expression.type === "Identifier" || first.expression.type === "ThisExpression";
11730
+ case "Identifier":
11731
+ return !!first.typeAnnotation || !!first.optional;
11732
+ default:
11733
+ return false;
11734
+ }
11735
+ }
11624
11736
  var ClassMemberModifiers = buildModifiersMap(["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"], ["in", "out"]);
11625
11737
  var IndexSignatureModifiers = buildModifiersMap(["readonly"], ["declare", "abstract", "private", "protected", "public", "static", "override"]);
11626
11738
  var BindingElementModifiers = buildModifiersMap(["public", "private", "protected", "override", "readonly"]);
@@ -12427,15 +12539,15 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
12427
12539
  return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(114) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
12428
12540
  }
12429
12541
  tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
12430
- const node = this.startNode();
12542
+ const startLoc = this.state.startLoc;
12431
12543
  const hasLeadingOperator = this.eat(operator);
12432
- const types2 = [];
12433
- do {
12434
- types2.push(parseConstituentType());
12435
- } while (this.eat(operator));
12436
- if (types2.length === 1 && !hasLeadingOperator) {
12437
- return types2[0];
12544
+ const first = parseConstituentType();
12545
+ if (!hasLeadingOperator && !this.match(operator)) {
12546
+ return first;
12438
12547
  }
12548
+ const node = this.startNodeAt(startLoc);
12549
+ const types2 = [first];
12550
+ while (this.eat(operator)) types2.push(parseConstituentType());
12439
12551
  node.types = types2;
12440
12552
  return this.finishNode(node, kind);
12441
12553
  }
@@ -12500,17 +12612,18 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
12500
12612
  return this.tsInType(() => {
12501
12613
  const t = this.startNode();
12502
12614
  this.expect(returnToken);
12503
- const node = this.startNode();
12504
- const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
12615
+ const startLoc = this.state.startLoc;
12616
+ const asserts = this.match(108) && !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
12505
12617
  if (asserts && this.match(74)) {
12618
+ const node2 = this.startNodeAt(startLoc);
12506
12619
  let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
12507
12620
  if (thisTypePredicate.type === "TSThisType") {
12508
- node.parameterName = thisTypePredicate;
12509
- node.asserts = true;
12510
- node.typeAnnotation = null;
12511
- thisTypePredicate = this.finishNode(node, "TSTypePredicate");
12621
+ node2.parameterName = thisTypePredicate;
12622
+ node2.asserts = true;
12623
+ node2.typeAnnotation = null;
12624
+ thisTypePredicate = this.finishNode(node2, "TSTypePredicate");
12512
12625
  } else {
12513
- this.resetStartLocationFromNode(thisTypePredicate, node);
12626
+ this.resetStartLocationFromNode(thisTypePredicate, node2);
12514
12627
  thisTypePredicate.asserts = true;
12515
12628
  }
12516
12629
  t.typeAnnotation = thisTypePredicate;
@@ -12521,12 +12634,14 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
12521
12634
  if (!asserts) {
12522
12635
  return this.tsParseTypeAnnotation(false, t);
12523
12636
  }
12524
- node.parameterName = this.parseIdentifier();
12525
- node.asserts = asserts;
12526
- node.typeAnnotation = null;
12527
- t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
12637
+ const node2 = this.startNodeAt(startLoc);
12638
+ node2.parameterName = this.parseIdentifier();
12639
+ node2.asserts = asserts;
12640
+ node2.typeAnnotation = null;
12641
+ t.typeAnnotation = this.finishNode(node2, "TSTypePredicate");
12528
12642
  return this.finishNode(t, "TSTypeAnnotation");
12529
12643
  }
12644
+ const node = this.startNodeAt(startLoc);
12530
12645
  const type = this.tsParseTypeAnnotation(false);
12531
12646
  node.parameterName = typePredicateVariable;
12532
12647
  node.typeAnnotation = type;
@@ -12983,11 +13098,17 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
12983
13098
  node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
12984
13099
  super.parseFunctionParams(node);
12985
13100
  node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
13101
+ const arrowStartPos = this.offsetToSourcePos(startLoc.index);
13102
+ if (node.returnType && this.match(15) && this.tsIsArrowReturnTypeRestrictedAt(arrowStartPos)) {
13103
+ this.tsArrowReturnTypeAt.set(arrowStartPos, node.returnType.start);
13104
+ }
12986
13105
  this.expect(15);
12987
13106
  return node;
12988
13107
  });
12989
13108
  if (!res) return;
12990
- return super.parseArrowExpression(res, null, true);
13109
+ const startPos = this.offsetToSourcePos(startLoc.index);
13110
+ const parse3 = () => res.returnType && this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithDeferredArrowErrors(() => super.parseArrowExpression(res, null, true)) : super.parseArrowExpression(res, null, true);
13111
+ return this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithRestrictedArrowReturnType(parse3, this.hasPlugin("jsx") || this.state.tsArrowReturnTypeAllowed) : parse3();
12991
13112
  }
12992
13113
  tsParseTypeArgumentsInExpression() {
12993
13114
  if (this.reScan_lt() !== 43) return;
@@ -13139,7 +13260,8 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13139
13260
  }
13140
13261
  if (this.match(43) || this.match(47)) {
13141
13262
  let missingParenErrorLoc;
13142
- const result = this.tsTryParseAndCatch(() => {
13263
+ let parsingAsyncArrow = true;
13264
+ const parseAttempt = () => {
13143
13265
  if (!noCalls && this.atPossibleAsyncArrow(base)) {
13144
13266
  const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
13145
13267
  if (asyncArrowFn) {
@@ -13147,6 +13269,7 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13147
13269
  return asyncArrowFn;
13148
13270
  }
13149
13271
  }
13272
+ parsingAsyncArrow = false;
13150
13273
  const typeArguments = this.tsParseTypeArgumentsInExpression();
13151
13274
  if (!typeArguments) return;
13152
13275
  if (isOptionalCall && !this.match(6)) {
@@ -13177,7 +13300,13 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13177
13300
  node.expression = base;
13178
13301
  node.typeArguments = typeArguments;
13179
13302
  return this.finishNode(node, "TSInstantiationExpression");
13180
- });
13303
+ };
13304
+ const attempt = this.tryParse((abort) => parseAttempt() || abort());
13305
+ if (attempt.thrown && parsingAsyncArrow && this.tsShouldKeepArrowErrorAt(attempt.error, this.offsetToSourcePos(startLoc.index))) {
13306
+ throw attempt.error;
13307
+ }
13308
+ const result = attempt.node;
13309
+ if (result && attempt.error) this.state = attempt.failState;
13181
13310
  if (missingParenErrorLoc) {
13182
13311
  this.unexpected(missingParenErrorLoc, 6);
13183
13312
  }
@@ -13567,17 +13696,36 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13567
13696
  return expr;
13568
13697
  }
13569
13698
  }
13699
+ const startPos = this.offsetToSourcePos(startLoc.index);
13700
+ const isRestricted = this.tsIsArrowReturnTypeRestrictedAt(startPos);
13701
+ const allowsReturnType = isRestricted && this.state.tsArrowReturnTypeAllowed;
13570
13702
  this.next();
13571
13703
  const node = this.startNodeAt(startLoc);
13572
13704
  node.test = expr;
13573
- const oldInConditionalConsequent = this.state.inConditionalConsequent;
13574
- this.state.inConditionalConsequent = true;
13575
- node.consequent = this.parseMaybeAssignAllowIn();
13576
- this.state.inConditionalConsequent = oldInConditionalConsequent;
13705
+ node.consequent = this.tsParseWithRestrictedArrowReturnType(() => this.parseMaybeAssignAllowIn());
13577
13706
  this.expect(10);
13578
- node.alternate = this.parseMaybeAssign();
13707
+ node.alternate = isRestricted ? this.tsParseWithRestrictedArrowReturnType(() => this.parseMaybeAssign(), allowsReturnType) : this.parseMaybeAssign();
13579
13708
  return this.finishNode(node, "ConditionalExpression");
13580
13709
  }
13710
+ tsIsArrowReturnTypeRestrictedAt(sourcePos) {
13711
+ return this.state.tsArrowReturnTypeRestrictionAt === sourcePos;
13712
+ }
13713
+ tsRestrictArrowReturnTypeAt(sourcePos, allowsReturnType, genericParams = false) {
13714
+ this.state.tsArrowReturnTypeRestrictionAt = sourcePos;
13715
+ this.state.tsArrowReturnTypeAllowed = allowsReturnType;
13716
+ this.state.tsGenericArrowParams = genericParams;
13717
+ }
13718
+ tsParseWithRestrictedArrowReturnType(parse3, allowsReturnType = false, genericParams = false) {
13719
+ const oldAllowed = this.state.tsArrowReturnTypeAllowed;
13720
+ const oldGeneric = this.state.tsGenericArrowParams;
13721
+ const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
13722
+ this.tsRestrictArrowReturnTypeAt(this.state.start, allowsReturnType, genericParams);
13723
+ const result = parse3();
13724
+ this.state.tsArrowReturnTypeRestrictionAt = oldStart;
13725
+ this.state.tsArrowReturnTypeAllowed = oldAllowed;
13726
+ this.state.tsGenericArrowParams = oldGeneric;
13727
+ return result;
13728
+ }
13581
13729
  parseParenItem(node, startLoc) {
13582
13730
  const newNode = super.parseParenItem(node, startLoc);
13583
13731
  if (this.eat(13)) {
@@ -13743,13 +13891,82 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13743
13891
  this.resetEndLocation(decl.id);
13744
13892
  }
13745
13893
  }
13746
- parseAsyncArrowFromCallExpression(node, call) {
13747
- if (this.match(10)) {
13748
- node.returnType = this.tsParseTypeAnnotation();
13894
+ parseMaybeAssign(refExpressionErrors, isParenItem) {
13895
+ const startPos = this.state.start;
13896
+ if (!this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
13897
+ return this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
13898
+ }
13899
+ const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
13900
+ const oldAllowed = this.state.tsArrowReturnTypeAllowed;
13901
+ const oldGeneric = this.state.tsGenericArrowParams;
13902
+ const node = this.match(6) || this.match(43) || this.isContextual(92) ? this.tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, isParenItem) : this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
13903
+ this.state.tsArrowReturnTypeRestrictionAt = oldStart;
13904
+ this.state.tsArrowReturnTypeAllowed = oldAllowed;
13905
+ this.state.tsGenericArrowParams = oldGeneric;
13906
+ return node;
13907
+ }
13908
+ tsParseWithDeferredArrowErrors(parse3) {
13909
+ if (this.optionFlags & 4096) return parse3();
13910
+ this.optionFlags |= 4096;
13911
+ try {
13912
+ return parse3();
13913
+ } finally {
13914
+ this.optionFlags &= -4097;
13749
13915
  }
13750
- return super.parseAsyncArrowFromCallExpression(node, call);
13751
13916
  }
13752
- parseMaybeAssign(refExpressionErrors, isParenItem) {
13917
+ tsShouldKeepArrowErrorAt(error, startPos) {
13918
+ if (!this.tsIsArrowReturnTypeRestrictedAt(startPos)) return false;
13919
+ const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
13920
+ return returnTypeStart !== void 0 && !tsIsInvalidArrowParamsError(error, returnTypeStart);
13921
+ }
13922
+ tsArrowReturnTypeAt = /* @__PURE__ */ new Map();
13923
+ tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, isParenItem) {
13924
+ if (!this.noArrowAt.has(startPos)) {
13925
+ const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
13926
+ const parse3 = () => this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
13927
+ let state = this.state.clone();
13928
+ const {
13929
+ tokensLength
13930
+ } = state;
13931
+ this.tsArrowReturnTypeAt.delete(startPos);
13932
+ let result = this.tryParse(parse3, state);
13933
+ const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
13934
+ if (result.thrown && returnTypeStart !== void 0 && !tsIsInvalidArrowParamsError(result.error, returnTypeStart) && !(this.optionFlags & 4096)) {
13935
+ state = this.state.clone();
13936
+ this.optionFlags |= 4096;
13937
+ try {
13938
+ result = this.tryParse(parse3, state);
13939
+ } finally {
13940
+ this.optionFlags &= -4097;
13941
+ }
13942
+ }
13943
+ if (result.thrown) {
13944
+ if (!this.tsArrowReturnTypeAt.has(startPos)) throw result.error;
13945
+ } else {
13946
+ if (result.error) this.state = result.failState;
13947
+ const node = result.node;
13948
+ if (node.type !== "ArrowFunctionExpression" || !node.returnType || node.extra?.parenthesized) {
13949
+ return node;
13950
+ }
13951
+ const {
13952
+ start
13953
+ } = node.returnType;
13954
+ const hasInvalidParams = result.error != null && this.state.errors.slice(state.errors.length).some((error) => tsIsInvalidArrowParamsError(error, start));
13955
+ const isUnambiguous = node.typeParameters ? this.hasPlugin("jsx") : tsHasUnambiguousArrowParams(node.params);
13956
+ if (!hasInvalidParams && (allowsReturnType || this.match(10)) || isUnambiguous && !(hasInvalidParams && node.async)) {
13957
+ if (result.error && !(this.optionFlags & 4096)) {
13958
+ throw result.error;
13959
+ }
13960
+ return node;
13961
+ }
13962
+ }
13963
+ this.noArrowAt.add(startPos);
13964
+ this.state = state;
13965
+ this.state.tokensLength = tokensLength;
13966
+ }
13967
+ return this.tsParseMaybeAssign(refExpressionErrors, isParenItem);
13968
+ }
13969
+ tsParseMaybeAssign(refExpressionErrors, isParenItem) {
13753
13970
  let state;
13754
13971
  let jsx2;
13755
13972
  let typeCast;
@@ -13771,8 +13988,26 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13771
13988
  if (!state || state === this.state) state = this.state.clone();
13772
13989
  let typeParameters;
13773
13990
  const arrow = this.tryParse((abort) => {
13991
+ const startPos = this.state.start;
13992
+ if (this.noArrowAt.has(startPos)) abort();
13993
+ const allowsReturnType = !this.match(43) || this.state.tsArrowReturnTypeAllowed;
13994
+ const isRestricted = this.tsIsArrowReturnTypeRestrictedAt(startPos);
13774
13995
  typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
13775
- const expr = super.parseMaybeAssign(refExpressionErrors, isParenItem);
13996
+ let expr;
13997
+ if (isRestricted) {
13998
+ const paramsStartPos = this.state.start;
13999
+ this.tsArrowReturnTypeAt.delete(paramsStartPos);
14000
+ try {
14001
+ expr = this.tsParseWithRestrictedArrowReturnType(() => super.parseMaybeAssign(refExpressionErrors, isParenItem), allowsReturnType, true);
14002
+ } finally {
14003
+ const returnTypeStart = this.tsArrowReturnTypeAt.get(paramsStartPos);
14004
+ if (returnTypeStart !== void 0) {
14005
+ this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
14006
+ }
14007
+ }
14008
+ } else {
14009
+ expr = super.parseMaybeAssign(refExpressionErrors, isParenItem);
14010
+ }
13776
14011
  if (expr.type !== "ArrowFunctionExpression" || expr.extra?.parenthesized) {
13777
14012
  abort();
13778
14013
  }
@@ -13790,6 +14025,15 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13790
14025
  }
13791
14026
  return expr;
13792
14027
  }, state);
14028
+ if (jsx2 && arrow.node && arrow.error && !(this.optionFlags & 4096)) {
14029
+ throw arrow.error;
14030
+ }
14031
+ if (arrow.error && this.tsShouldKeepArrowErrorAt(arrow.error, state.start)) {
14032
+ if (!arrow.node) throw arrow.error;
14033
+ this.state = arrow.failState;
14034
+ if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
14035
+ return arrow.node;
14036
+ }
13793
14037
  if (!arrow.error && !arrow.aborted) {
13794
14038
  if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
13795
14039
  return arrow.node;
@@ -13827,6 +14071,9 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13827
14071
  }
13828
14072
  parseArrow(node) {
13829
14073
  if (this.match(10)) {
14074
+ const startPos = this.offsetToSourcePos(node.start);
14075
+ if (this.noArrowAt.has(startPos)) return;
14076
+ const returnTypeStart = this.sourceToOffsetPos(this.state.start);
13830
14077
  const result = this.tryParse((abort) => {
13831
14078
  const returnType = this.tsParseTypeOrTypePredicateAnnotation(10);
13832
14079
  if (this.canInsertSemicolon() || !this.match(15)) abort();
@@ -13836,6 +14083,9 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
13836
14083
  if (!result.thrown) {
13837
14084
  if (result.error) this.state = result.failState;
13838
14085
  node.returnType = result.node;
14086
+ if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
14087
+ this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
14088
+ }
13839
14089
  }
13840
14090
  }
13841
14091
  return super.parseArrow(node);
@@ -14003,19 +14253,46 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
14003
14253
  }
14004
14254
  return super.shouldParseArrow(params);
14005
14255
  }
14006
- shouldParseAsyncArrow() {
14007
- if (this.match(10)) {
14008
- if (this.state.inConditionalConsequent) return false;
14009
- return true;
14256
+ parseAsyncArrowHead(startLoc) {
14257
+ if (!this.match(10)) return super.parseAsyncArrowHead(startLoc);
14258
+ const returnTypeStart = this.sourceToOffsetPos(this.state.start);
14259
+ const result = this.tryParse((abort) => {
14260
+ const returnType = this.tsParseTypeAnnotation();
14261
+ if (!this.match(15)) abort();
14262
+ return returnType;
14263
+ });
14264
+ if (result.aborted || result.thrown) return void 0;
14265
+ if (result.error) this.state = result.failState;
14266
+ const startPos = this.offsetToSourcePos(startLoc.index);
14267
+ if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
14268
+ this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
14010
14269
  }
14011
- return super.shouldParseAsyncArrow();
14270
+ const node = this.startNodeAt(startLoc);
14271
+ node.returnType = result.node;
14272
+ return node;
14012
14273
  }
14013
- parseParenAndDistinguishExpression(canStartArrow) {
14014
- const oldInConditionalConsequent = this.state.inConditionalConsequent;
14015
- this.state.inConditionalConsequent = false;
14016
- const result = super.parseParenAndDistinguishExpression(canStartArrow);
14017
- this.state.inConditionalConsequent = oldInConditionalConsequent;
14018
- return result;
14274
+ atPossibleAsyncArrow(base) {
14275
+ return super.atPossibleAsyncArrow(base) && !this.noArrowAt.has(this.offsetToSourcePos(base.start));
14276
+ }
14277
+ parseMaybeConditional(refExpressionErrors) {
14278
+ if (!this.tsIsArrowReturnTypeRestrictedAt(this.state.start)) {
14279
+ return super.parseMaybeConditional(refExpressionErrors);
14280
+ }
14281
+ const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
14282
+ const expr = super.parseMaybeConditional(refExpressionErrors);
14283
+ if (tokenIsAssignment(this.state.type)) {
14284
+ this.tsRestrictArrowReturnTypeAt(this.nextTokenStart(), allowsReturnType);
14285
+ }
14286
+ return expr;
14287
+ }
14288
+ parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
14289
+ const startPos = this.offsetToSourcePos(node.start);
14290
+ if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
14291
+ const genericParams = this.state.tsGenericArrowParams;
14292
+ const parse3 = () => super.parseArrowExpression(node, params, isAsync, trailingCommaLoc);
14293
+ return this.tsParseWithRestrictedArrowReturnType(genericParams && node.returnType ? () => this.tsParseWithDeferredArrowErrors(parse3) : parse3, this.state.tsArrowReturnTypeAllowed || !genericParams && tsHasUnambiguousArrowParams(params));
14294
+ }
14295
+ return super.parseArrowExpression(node, params, isAsync, trailingCommaLoc);
14019
14296
  }
14020
14297
  canHaveLeadingDecorator() {
14021
14298
  return super.canHaveLeadingDecorator() || this.isAbstractClass();
@@ -14160,9 +14437,9 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
14160
14437
  hasTypeSpecifier = true;
14161
14438
  leftOfAs = firstAs;
14162
14439
  }
14163
- } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14440
+ } else if (this.tsIsStartOfModuleExportName()) {
14164
14441
  hasTypeSpecifier = true;
14165
- leftOfAs = this.parseIdentifier(true);
14442
+ leftOfAs = this.parseModuleExportName();
14166
14443
  }
14167
14444
  node.imported = leftOfAs;
14168
14445
  node.importKind = hasTypeSpecifier ? "type" : "value";
@@ -14175,20 +14452,20 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
14175
14452
  const firstAs = this.parseIdentifier();
14176
14453
  if (this.isContextual(90)) {
14177
14454
  const secondAs = this.parseIdentifier();
14178
- if (tokenIsKeywordOrIdentifier(this.state.type)) {
14455
+ if (this.tsIsStartOfModuleExportName()) {
14179
14456
  hasTypeSpecifier = true;
14180
14457
  node.local = firstAs;
14181
14458
  node.exported = this.parseModuleExportName();
14182
14459
  } else {
14183
14460
  node.exported = secondAs;
14184
14461
  }
14185
- } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14462
+ } else if (this.tsIsStartOfModuleExportName()) {
14186
14463
  node.exported = this.parseModuleExportName();
14187
14464
  } else {
14188
14465
  hasTypeSpecifier = true;
14189
14466
  node.local = firstAs;
14190
14467
  }
14191
- } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14468
+ } else if (this.tsIsStartOfModuleExportName()) {
14192
14469
  hasTypeSpecifier = true;
14193
14470
  node.local = this.parseModuleExportName();
14194
14471
  }
@@ -14196,7 +14473,10 @@ var typescript = (superClass) => class TypeScriptParserMixin extends superClass
14196
14473
  this.raise(TSErrors.TypeModifierIsUsedInTypeExports, local);
14197
14474
  }
14198
14475
  node.exportKind = hasTypeSpecifier ? "type" : "value";
14199
- node.exported ??= this.eatContextual(90) ? this.parseModuleExportName() : this.cloneIdentifier(node.local);
14476
+ node.exported ??= this.eatContextual(90) ? this.parseModuleExportName() : this.isStringModuleExportName(node.local) ? this.cloneStringLiteral(node.local) : this.cloneIdentifier(node.local);
14477
+ }
14478
+ tsIsStartOfModuleExportName() {
14479
+ return tokenIsKeywordOrIdentifier(this.state.type) || this.match(133);
14200
14480
  }
14201
14481
  fillOptionalPropertiesForTSESLint(node) {
14202
14482
  switch (node.type) {
@@ -16885,12 +17165,11 @@ function readCodePoint2(input, pos, lineStart, curLine, throwOnInvalid, errors)
16885
17165
  if (code2 !== null && code2 > 1114111) {
16886
17166
  if (throwOnInvalid) {
16887
17167
  errors.invalidCodePoint(pos, lineStart, curLine);
16888
- } else {
16889
- return {
16890
- code: null,
16891
- pos
16892
- };
16893
17168
  }
17169
+ return {
17170
+ code: null,
17171
+ pos
17172
+ };
16894
17173
  }
16895
17174
  } else {
16896
17175
  ({
@@ -27563,8 +27842,12 @@ function isScope(node, parent) {
27563
27842
  return isScopable(node);
27564
27843
  }
27565
27844
  function isSpecifierDefault(specifier) {
27566
- return isImportDefaultSpecifier(specifier) || isIdentifier(specifier.imported || specifier.exported, {
27845
+ if (isImportDefaultSpecifier(specifier)) return true;
27846
+ const name = specifier.imported || specifier.exported;
27847
+ return isIdentifier(name, {
27567
27848
  name: "default"
27849
+ }) || isStringLiteral(name, {
27850
+ value: "default"
27568
27851
  });
27569
27852
  }
27570
27853
  var RESERVED_WORDS_ES3_ONLY = /* @__PURE__ */ new Set(["abstract", "boolean", "byte", "char", "double", "enum", "final", "float", "goto", "implements", "int", "interface", "long", "native", "package", "private", "protected", "public", "short", "static", "synchronized", "throws", "transient", "volatile"]);
@@ -29082,15 +29365,6 @@ function ConditionalExpression$1(node, parent, parentId) {
29082
29365
  }
29083
29366
  return UnaryLike(node, parent, parentId);
29084
29367
  }
29085
- function OptionalMemberExpression$1(node, parent, parentId) {
29086
- switch (parentId) {
29087
- case 18:
29088
- return parent.callee === node;
29089
- case 109:
29090
- return parent.object === node;
29091
- }
29092
- return false;
29093
- }
29094
29368
  function AssignmentExpression$1(node, parent, parentId, tokenContext) {
29095
29369
  if (needsParenBeforeExpressionBrace(tokenContext) && node.left.type === "ObjectPattern") {
29096
29370
  return true;
@@ -29141,9 +29415,7 @@ var parens = /* @__PURE__ */ Object.defineProperty({
29141
29415
  LogicalExpression: LogicalExpression2,
29142
29416
  NullableTypeAnnotation: NullableTypeAnnotation$1,
29143
29417
  ObjectExpression: ObjectExpression$1,
29144
- OptionalCallExpression: OptionalMemberExpression$1,
29145
29418
  OptionalIndexedAccessType: OptionalIndexedAccessType$1,
29146
- OptionalMemberExpression: OptionalMemberExpression$1,
29147
29419
  SequenceExpression: SequenceExpression$1,
29148
29420
  SpreadElement: UnaryLike,
29149
29421
  TSAsExpression: TSAsExpression$1,
@@ -29679,6 +29951,9 @@ function VariableDeclaration2(node, parent) {
29679
29951
  this.word(kind);
29680
29952
  }
29681
29953
  this.space();
29954
+ if (kind === "using" && parent?.type === "ForOfStatement" && parent.left === node) {
29955
+ this.tokenContext |= 256;
29956
+ }
29682
29957
  let hasInits = false;
29683
29958
  if (!isFor2(parent)) {
29684
29959
  for (const declar of node.declarations) {
@@ -29956,6 +30231,10 @@ function TSParameterProperty2(node) {
29956
30231
  this.word(node.accessibility);
29957
30232
  this.space();
29958
30233
  }
30234
+ if (node.override) {
30235
+ this.word("override");
30236
+ this.space();
30237
+ }
29959
30238
  if (node.readonly) {
29960
30239
  this.word("readonly");
29961
30240
  this.space();
@@ -30837,7 +31116,11 @@ function Identifier2(node) {
30837
31116
  if (this._buf._map && node.loc?.identifierName && node.loc.identifierName !== node.name) {
30838
31117
  this.sourceIdentifierName(node.loc.identifierName);
30839
31118
  }
30840
- this.word(this.tokenMap ? lastRawIdentResult : node.name);
31119
+ let name = this.tokenMap ? lastRawIdentResult : node.name;
31120
+ if (name === "of" && this.tokenContext & 256) {
31121
+ name = "o\\u0066";
31122
+ }
31123
+ this.word(name);
30841
31124
  }
30842
31125
  function ArgumentPlaceholder2() {
30843
31126
  this.tokenChar(63);
@@ -30918,7 +31201,7 @@ function NumericLiteral2(node) {
30918
31201
  const opts = this.format.jsescOption;
30919
31202
  const value = node.value;
30920
31203
  const str = value + "";
30921
- if (opts.numbers) {
31204
+ if (opts.numbers && Number.isFinite(value) && (opts.numbers === "decimal" || Number.isInteger(value))) {
30922
31205
  this.number((0, import_jsesc.default)(value, opts), value);
30923
31206
  } else if (raw == null) {
30924
31207
  this.number(str, value);
@@ -32210,9 +32493,11 @@ function newCalleeNeedsParens(node) {
32210
32493
  return true;
32211
32494
  case "MemberExpression":
32212
32495
  current = current.object;
32496
+ if (isWrappedOptionalChain(current)) return false;
32213
32497
  break;
32214
32498
  case "TaggedTemplateExpression":
32215
32499
  current = current.tag;
32500
+ if (isWrappedOptionalChain(current)) return false;
32216
32501
  break;
32217
32502
  case "TSInstantiationExpression":
32218
32503
  case "TSNonNullExpression":
@@ -32223,7 +32508,7 @@ function newCalleeNeedsParens(node) {
32223
32508
  }
32224
32509
  }
32225
32510
  }
32226
- function templateTagNeedsParens(node) {
32511
+ function isWrappedOptionalChain(node) {
32227
32512
  let current = node;
32228
32513
  while (true) {
32229
32514
  switch (current.type) {
@@ -32231,6 +32516,9 @@ function templateTagNeedsParens(node) {
32231
32516
  case "OptionalMemberExpression":
32232
32517
  return true;
32233
32518
  case "TSInstantiationExpression":
32519
+ if (current !== node) return false;
32520
+ current = current.expression;
32521
+ break;
32234
32522
  case "TSNonNullExpression":
32235
32523
  current = current.expression;
32236
32524
  break;
@@ -32248,7 +32536,17 @@ function parentNeedsParens(node, parent, parentId) {
32248
32536
  break;
32249
32537
  case 222:
32250
32538
  if (parent.tag === node) {
32251
- return templateTagNeedsParens(node);
32539
+ return isWrappedOptionalChain(node);
32540
+ }
32541
+ break;
32542
+ case 18:
32543
+ if (parent.callee === node) {
32544
+ return isWrappedOptionalChain(node);
32545
+ }
32546
+ break;
32547
+ case 109:
32548
+ if (parent.object === node) {
32549
+ return isWrappedOptionalChain(node);
32252
32550
  }
32253
32551
  break;
32254
32552
  case 43:
@@ -34504,14 +34802,29 @@ function createTemplateBuilder(formatter, defaultOpts) {
34504
34802
  });
34505
34803
  }
34506
34804
  function extendedTrace(fn) {
34507
- const rootErr = new Error();
34805
+ let rootStack;
34806
+ try {
34807
+ const {
34808
+ stack
34809
+ } = new Error();
34810
+ if (typeof stack === "string") rootStack = stack;
34811
+ } catch {
34812
+ }
34508
34813
  return (arg) => {
34509
34814
  try {
34510
34815
  return fn(arg);
34511
34816
  } catch (err) {
34512
- err.stack += `
34817
+ if (rootStack !== void 0) {
34818
+ try {
34819
+ const error = err;
34820
+ if (typeof error.stack === "string") {
34821
+ error.stack += `
34513
34822
  =============
34514
- ${rootErr.stack.split("\n").slice(3).join("\n")}`;
34823
+ ${rootStack.split("\n").slice(3).join("\n")}`;
34824
+ }
34825
+ } catch {
34826
+ }
34827
+ }
34515
34828
  throw err;
34516
34829
  }
34517
34830
  };
@@ -34942,7 +35255,7 @@ function verify$1(visitor) {
34942
35255
  }
34943
35256
  if (shouldIgnoreKey(nodeType)) continue;
34944
35257
  if (!TYPES2.includes(nodeType)) {
34945
- throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.1.0"}`);
35258
+ throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.1.2"}`);
34946
35259
  }
34947
35260
  const visitors2 = visitor[nodeType];
34948
35261
  if (typeof visitors2 === "object") {
@@ -35116,9 +35429,9 @@ var getRenameVisitor = () => renameVisitor ??= explode$1({
35116
35429
  node.shorthand = false;
35117
35430
  }
35118
35431
  },
35119
- "AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
35432
+ "AssignmentExpression|ForXStatement|Declaration|VariableDeclarator"(path, state) {
35120
35433
  if (path.isVariableDeclaration()) return;
35121
- const ids = path.isAssignmentExpression() ? getAssignmentIdentifiers$1(path.node) : path.getOuterBindingIdentifiers();
35434
+ const ids = path.isAssignmentExpression() || path.isForXStatement() ? getAssignmentIdentifiers$1(path.node) : path.getOuterBindingIdentifiers();
35122
35435
  for (const name in ids) {
35123
35436
  if (name === state.oldName) ids[name].name = state.newName;
35124
35437
  }
@@ -37401,6 +37714,23 @@ function deopt(path, state) {
37401
37714
  state.confident = false;
37402
37715
  }
37403
37716
  var Globals = /* @__PURE__ */ new Map([["undefined", void 0], ["Infinity", Infinity], ["NaN", NaN]]);
37717
+ function isVarDeclarationReachedBefore(declaration, reference) {
37718
+ const sequentialAncestors = /* @__PURE__ */ new Set();
37719
+ for (let child = declaration, parent = child.parentPath; parent != null && isSequentialStep(child, parent); child = parent, parent = child.parentPath) {
37720
+ sequentialAncestors.add(parent.node);
37721
+ }
37722
+ for (let p = reference.parentPath; p; p = p.parentPath) {
37723
+ if (sequentialAncestors.has(p.node)) return true;
37724
+ }
37725
+ return false;
37726
+ }
37727
+ function isSequentialStep(child, parent) {
37728
+ const {
37729
+ listKey,
37730
+ key
37731
+ } = child;
37732
+ return listKey === "declarations" && parent.isVariableDeclaration() || listKey === "body" && (parent.isBlockStatement() || parent.isProgram() || parent.isStaticBlock() || parent.isTSModuleBlock()) || listKey === "consequent" && parent.isSwitchCase() || key === "init" && parent.isForStatement() || key === "declaration" && parent.isExportNamedDeclaration() || key === "body" && parent.isLabeledStatement() && child.isVariableDeclaration();
37733
+ }
37404
37734
  function evaluateCached(path, state) {
37405
37735
  const {
37406
37736
  node
@@ -37495,21 +37825,9 @@ function _evaluate(path, state) {
37495
37825
  deopt(binding.path, state);
37496
37826
  return;
37497
37827
  }
37498
- const bindingPathScope = binding.path.scope;
37499
- if (binding.kind === "var" && bindingPathScope !== binding.scope) {
37500
- let hasUnsafeBlock = !bindingPathScope.path.parentPath.isBlockStatement();
37501
- for (let scope2 = bindingPathScope.parent; scope2; scope2 = scope2.parent) {
37502
- if (scope2 === path.scope) {
37503
- if (hasUnsafeBlock) {
37504
- deopt(binding.path, state);
37505
- return;
37506
- }
37507
- break;
37508
- }
37509
- if (scope2.path.parentPath?.isBlockStatement()) {
37510
- hasUnsafeBlock = true;
37511
- }
37512
- }
37828
+ if (binding.kind === "var" && !isVarDeclarationReachedBefore(binding.path, path)) {
37829
+ deopt(binding.path, state);
37830
+ return;
37513
37831
  }
37514
37832
  if (binding.hasValue) {
37515
37833
  return binding.value;
@@ -38414,9 +38732,11 @@ function referencesImport(moduleSource, importName) {
38414
38732
  if (path.isImportNamespaceSpecifier()) {
38415
38733
  return !path.node.exportsFilter && importName === "*";
38416
38734
  }
38417
- if (path.isImportSpecifier() && isIdentifier4(path.node.imported, {
38735
+ if (path.isImportSpecifier() && (isIdentifier4(path.node.imported, {
38418
38736
  name: importName
38419
- })) {
38737
+ }) || isStringLiteral3(path.node.imported, {
38738
+ value: importName
38739
+ }))) {
38420
38740
  return true;
38421
38741
  }
38422
38742
  return false;