@diffci.com/diffci 0.3.64 → 0.3.66

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.
Files changed (110) hide show
  1. package/dist-client/src/client/isolated-worktree.d.ts +16 -0
  2. package/dist-client/src/client/isolated-worktree.js +67 -1
  3. package/dist-client/src/client/mcp.js +14 -0
  4. package/dist-client/src/client/telemetry.d.ts +1 -1
  5. package/dist-client/src/client/telemetry.js +2 -1
  6. package/dist-client/src/client/usage-signal.d.ts +10 -2
  7. package/dist-client/src/client/usage-signal.js +11 -0
  8. package/node_modules/@babel/helper-string-parser/lib/index.js +15 -6
  9. package/node_modules/@babel/helper-string-parser/lib/index.js.map +1 -1
  10. package/node_modules/@babel/helper-string-parser/package.json +1 -1
  11. package/node_modules/@babel/parser/lib/index.js +326 -93
  12. package/node_modules/@babel/parser/lib/index.js.map +1 -1
  13. package/node_modules/@babel/parser/package.json +3 -3
  14. package/node_modules/@babel/parser/typings/babel-parser.d.ts +23 -25
  15. package/node_modules/@babel/types/lib/ast-types/generated/index.js.map +1 -1
  16. package/node_modules/@babel/types/lib/clone/cloneNode.js.map +1 -1
  17. package/node_modules/@babel/types/lib/definitions/core.js +4 -0
  18. package/node_modules/@babel/types/lib/definitions/core.js.map +1 -1
  19. package/node_modules/@babel/types/lib/index-legacy.d.ts +1 -0
  20. package/node_modules/@babel/types/lib/index.d.ts +5 -5
  21. package/node_modules/@babel/types/lib/index.js.flow +1 -0
  22. package/node_modules/@babel/types/lib/validators/is.js.map +1 -1
  23. package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +5 -1
  24. package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js.map +1 -1
  25. package/node_modules/@babel/types/package.json +4 -4
  26. package/node_modules/@diffci.com/core/README.md +1 -1
  27. package/node_modules/@diffci.com/core/dist/git/git-diff.js +7 -4
  28. package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
  29. package/node_modules/@diffci.com/core/dist/git/types.d.ts +4 -0
  30. package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +16 -10
  31. package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
  32. package/node_modules/@diffci.com/core/dist/repo/graph.js +8 -3
  33. package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
  34. package/node_modules/@diffci.com/core/dist/repo/impact.js +4 -1
  35. package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
  36. package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.d.ts +11 -0
  37. package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.js +45 -0
  38. package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.js.map +1 -1
  39. package/node_modules/@diffci.com/core/package.json +1 -1
  40. package/node_modules/@diffci.com/core/src/git/git-diff.ts +6 -4
  41. package/node_modules/@diffci.com/core/src/git/types.ts +4 -0
  42. package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +16 -9
  43. package/node_modules/@diffci.com/core/src/repo/graph.ts +8 -3
  44. package/node_modules/@diffci.com/core/src/repo/impact.ts +4 -1
  45. package/node_modules/@diffci.com/core/src/repo/npm-lockfile.ts +39 -0
  46. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +115 -71
  47. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +2 -2
  48. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +115 -71
  49. package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +2 -2
  50. package/node_modules/@jridgewell/sourcemap-codec/package.json +2 -1
  51. package/node_modules/@jridgewell/sourcemap-codec/src/range-mappings.ts +47 -0
  52. package/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts +66 -46
  53. package/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +27 -11
  54. package/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts +13 -17
  55. package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.cts +5 -0
  56. package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.cts.map +1 -0
  57. package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts +5 -0
  58. package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts.map +1 -0
  59. package/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map +1 -1
  60. package/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map +1 -1
  61. package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts +2 -0
  62. package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map +1 -1
  63. package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts +2 -0
  64. package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map +1 -1
  65. package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts +4 -2
  66. package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map +1 -1
  67. package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts +4 -2
  68. package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map +1 -1
  69. package/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js +6 -2
  70. package/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6 -2
  71. package/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js +6 -2
  72. package/node_modules/@vue/compiler-core/package.json +4 -4
  73. package/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +8 -8
  74. package/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +8 -8
  75. package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +14 -14
  76. package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +2 -2
  77. package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +1 -1
  78. package/node_modules/@vue/compiler-dom/dist/compiler-dom.global.js +14 -14
  79. package/node_modules/@vue/compiler-dom/dist/compiler-dom.global.prod.js +2 -2
  80. package/node_modules/@vue/compiler-dom/package.json +3 -3
  81. package/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +1847 -1370
  82. package/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +6462 -6187
  83. package/node_modules/@vue/compiler-sfc/package.json +11 -11
  84. package/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +32 -9
  85. package/node_modules/@vue/compiler-ssr/package.json +3 -3
  86. package/node_modules/@vue/shared/dist/shared.cjs.js +11 -15
  87. package/node_modules/@vue/shared/dist/shared.cjs.prod.js +11 -15
  88. package/node_modules/@vue/shared/dist/shared.esm-bundler.js +11 -15
  89. package/node_modules/@vue/shared/package.json +1 -1
  90. package/node_modules/postcss/lib/css-syntax-error.js +6 -4
  91. package/node_modules/postcss/lib/declaration.d.ts +2 -2
  92. package/node_modules/postcss/lib/map-generator.js +12 -2
  93. package/node_modules/postcss/lib/processor.js +1 -1
  94. package/node_modules/postcss/lib/tokenize.js +6 -13
  95. package/node_modules/postcss/package.json +1 -1
  96. package/node_modules/source-map-js/README.md +192 -176
  97. package/node_modules/source-map-js/lib/array-set.js +5 -3
  98. package/node_modules/source-map-js/lib/base64-vlq.js +5 -9
  99. package/node_modules/source-map-js/lib/base64.js +13 -12
  100. package/node_modules/source-map-js/lib/binary-search.js +10 -6
  101. package/node_modules/source-map-js/lib/mapping-list.js +12 -7
  102. package/node_modules/source-map-js/lib/quick-sort.js +93 -23
  103. package/node_modules/source-map-js/lib/source-map-consumer.js +272 -194
  104. package/node_modules/source-map-js/lib/source-map-generator.js +146 -106
  105. package/node_modules/source-map-js/lib/source-node.js +144 -118
  106. package/node_modules/source-map-js/lib/util.js +56 -37
  107. package/node_modules/source-map-js/package.json +14 -7
  108. package/node_modules/source-map-js/source-map.d.ts +177 -63
  109. package/node_modules/source-map-js/source-map.js +4 -2
  110. package/package.json +3 -3
@@ -120,8 +120,9 @@ var StandardErrors = {
120
120
  EscapedCharNotAnIdentifier: "Invalid Unicode escape.",
121
121
  ExportBindingIsString: ({
122
122
  localName,
123
- exportName
124
- }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
123
+ exportName,
124
+ typeModifierIn
125
+ }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export ${typeModifierIn === "declaration" ? "type " : ""}{ ${typeModifierIn === "specifier" ? "type " : ""}'${localName}' as '${exportName}' } from 'some-module'\`?`,
125
126
  ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
126
127
  ForInOfLoopInitializer: ({
127
128
  type
@@ -2994,7 +2995,6 @@ var flow = superClass => class FlowParserMixin extends superClass {
2994
2995
  }
2995
2996
  this.expect(17);
2996
2997
  const state = this.state.clone();
2997
- const originalNoArrowAt = this.state.noArrowAt;
2998
2998
  const node = this.startNodeAt(startLoc);
2999
2999
  let {
3000
3000
  consequent,
@@ -3002,12 +3002,10 @@ var flow = superClass => class FlowParserMixin extends superClass {
3002
3002
  } = this.tryParseConditionalConsequent();
3003
3003
  let [valid, invalid] = this.getArrowLikeExpressions(consequent);
3004
3004
  if (failed || invalid.length > 0) {
3005
- const noArrowAt = [...originalNoArrowAt];
3006
3005
  if (invalid.length > 0) {
3007
3006
  this.state = state;
3008
- this.state.noArrowAt = noArrowAt;
3009
3007
  for (let i = 0; i < invalid.length; i++) {
3010
- noArrowAt.push(invalid[i].start);
3008
+ this.noArrowAt.add(this.offsetToSourcePos(invalid[i].start));
3011
3009
  }
3012
3010
  ({
3013
3011
  consequent,
@@ -3020,8 +3018,7 @@ var flow = superClass => class FlowParserMixin extends superClass {
3020
3018
  }
3021
3019
  if (failed && valid.length === 1) {
3022
3020
  this.state = state;
3023
- noArrowAt.push(valid[0].start);
3024
- this.state.noArrowAt = noArrowAt;
3021
+ this.noArrowAt.add(this.offsetToSourcePos(valid[0].start));
3025
3022
  ({
3026
3023
  consequent,
3027
3024
  failed
@@ -3029,7 +3026,6 @@ var flow = superClass => class FlowParserMixin extends superClass {
3029
3026
  }
3030
3027
  }
3031
3028
  this.getArrowLikeExpressions(consequent, true);
3032
- this.state.noArrowAt = originalNoArrowAt;
3033
3029
  this.expect(14);
3034
3030
  node.test = expr;
3035
3031
  node.consequent = consequent;
@@ -3506,8 +3502,8 @@ var flow = superClass => class FlowParserMixin extends superClass {
3506
3502
  }
3507
3503
  return super.parseAsyncArrowFromCallExpression(node, call);
3508
3504
  }
3509
- shouldParseAsyncArrow() {
3510
- return this.match(14) || super.shouldParseAsyncArrow();
3505
+ parseAsyncArrowHead(startLoc) {
3506
+ return this.match(14) ? this.startNodeAt(startLoc) : super.parseAsyncArrowHead(startLoc);
3511
3507
  }
3512
3508
  parseMaybeAssign(refExpressionErrors, afterLeftParse) {
3513
3509
  var _jsx;
@@ -3608,16 +3604,16 @@ var flow = superClass => class FlowParserMixin extends superClass {
3608
3604
  super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
3609
3605
  }
3610
3606
  parseParenAndDistinguishExpression(canBeArrow) {
3611
- return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)));
3607
+ return super.parseParenAndDistinguishExpression(canBeArrow && !this.noArrowAt.has(this.state.start));
3612
3608
  }
3613
3609
  parseSubscripts(base, startLoc, noCalls) {
3614
- if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.includes(startLoc.index)) {
3610
+ if (base.type === "Identifier" && base.name === "async" && this.noArrowAt.has(this.offsetToSourcePos(startLoc.index))) {
3615
3611
  this.next();
3616
3612
  const node = this.startNodeAt(startLoc);
3617
3613
  node.callee = base;
3618
3614
  node.arguments = super.parseCallExpressionArguments();
3619
3615
  base = this.finishNode(node, "CallExpression");
3620
- } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) {
3616
+ } else if (this.match(47) && this.atPossibleAsyncArrow(base)) {
3621
3617
  const state = this.state.clone();
3622
3618
  const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state);
3623
3619
  if (!arrow.error && !arrow.aborted) return arrow.node;
@@ -4960,6 +4956,8 @@ class BaseParser {
4960
4956
  constructor() {
4961
4957
  this.sawUnambiguousESM = false;
4962
4958
  this.ambiguousScriptDifferentAst = false;
4959
+ this.classHeritageStart = -1;
4960
+ this.noArrowAt = new Set();
4963
4961
  }
4964
4962
  sourceToOffsetPos(sourcePos) {
4965
4963
  return sourcePos + this.startIndex;
@@ -5182,7 +5180,7 @@ class CommentsParser extends BaseParser {
5182
5180
  }
5183
5181
  class State {
5184
5182
  constructor() {
5185
- this.flags = 1024;
5183
+ this.flags = 512;
5186
5184
  this.startIndex = void 0;
5187
5185
  this.curLine = void 0;
5188
5186
  this.lineStart = void 0;
@@ -5190,8 +5188,8 @@ class State {
5190
5188
  this.endLoc = void 0;
5191
5189
  this.errors = [];
5192
5190
  this.potentialArrowAt = -1;
5193
- this.noArrowAt = [];
5194
5191
  this.noArrowParamsConversionAt = [];
5192
+ this.tsArrowReturnTypeRestrictionAt = -1;
5195
5193
  this.regExpAllowedAt = -1;
5196
5194
  this.topicContext = {
5197
5195
  maxNumOfResolvableTopics: 0,
@@ -5273,36 +5271,42 @@ class State {
5273
5271
  set inDisallowConditionalTypesContext(v) {
5274
5272
  if (v) this.flags |= 128;else this.flags &= -129;
5275
5273
  }
5276
- get inConditionalConsequent() {
5274
+ get soloAwait() {
5277
5275
  return (this.flags & 256) > 0;
5278
5276
  }
5279
- set inConditionalConsequent(v) {
5277
+ set soloAwait(v) {
5280
5278
  if (v) this.flags |= 256;else this.flags &= -257;
5281
5279
  }
5282
- get soloAwait() {
5280
+ get canStartJSXElement() {
5283
5281
  return (this.flags & 512) > 0;
5284
5282
  }
5285
- set soloAwait(v) {
5283
+ set canStartJSXElement(v) {
5286
5284
  if (v) this.flags |= 512;else this.flags &= -513;
5287
5285
  }
5288
- get canStartJSXElement() {
5286
+ get containsEsc() {
5289
5287
  return (this.flags & 1024) > 0;
5290
5288
  }
5291
- set canStartJSXElement(v) {
5289
+ set containsEsc(v) {
5292
5290
  if (v) this.flags |= 1024;else this.flags &= -1025;
5293
5291
  }
5294
- get containsEsc() {
5292
+ get hasTopLevelAwait() {
5295
5293
  return (this.flags & 2048) > 0;
5296
5294
  }
5297
- set containsEsc(v) {
5295
+ set hasTopLevelAwait(v) {
5298
5296
  if (v) this.flags |= 2048;else this.flags &= -2049;
5299
5297
  }
5300
- get hasTopLevelAwait() {
5298
+ get tsArrowReturnTypeAllowed() {
5301
5299
  return (this.flags & 4096) > 0;
5302
5300
  }
5303
- set hasTopLevelAwait(v) {
5301
+ set tsArrowReturnTypeAllowed(v) {
5304
5302
  if (v) this.flags |= 4096;else this.flags &= -4097;
5305
5303
  }
5304
+ get tsGenericArrowParams() {
5305
+ return (this.flags & 8192) > 0;
5306
+ }
5307
+ set tsGenericArrowParams(v) {
5308
+ if (v) this.flags |= 8192;else this.flags &= -8193;
5309
+ }
5306
5310
  curPosition() {
5307
5311
  return new Position(this.curLine, this.pos - this.lineStart, this.pos + this.startIndex);
5308
5312
  }
@@ -5316,8 +5320,8 @@ class State {
5316
5320
  state.endLoc = this.endLoc;
5317
5321
  state.errors = this.errors.slice();
5318
5322
  state.potentialArrowAt = this.potentialArrowAt;
5319
- state.noArrowAt = this.noArrowAt.slice();
5320
5323
  state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice();
5324
+ state.tsArrowReturnTypeRestrictionAt = this.tsArrowReturnTypeRestrictionAt;
5321
5325
  state.topicContext = this.topicContext;
5322
5326
  state.regExpAllowedAt = this.regExpAllowedAt;
5323
5327
  state.labels = this.labels.slice();
@@ -5596,20 +5600,29 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
5596
5600
  let code;
5597
5601
  if (ch === 123) {
5598
5602
  ++pos;
5603
+ const rightCurlyBracePos = input.indexOf("}", pos);
5604
+ if (rightCurlyBracePos === -1) {
5605
+ if (throwOnInvalid) {
5606
+ errors.invalidEscapeSequence(pos, lineStart, curLine);
5607
+ }
5608
+ return {
5609
+ code: null,
5610
+ pos
5611
+ };
5612
+ }
5599
5613
  ({
5600
5614
  code,
5601
5615
  pos
5602
- } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
5616
+ } = readHexChar(input, pos, lineStart, curLine, rightCurlyBracePos - pos, true, throwOnInvalid, errors));
5603
5617
  ++pos;
5604
5618
  if (code !== null && code > 0x10ffff) {
5605
5619
  if (throwOnInvalid) {
5606
5620
  errors.invalidCodePoint(pos, lineStart, curLine);
5607
- } else {
5608
- return {
5609
- code: null,
5610
- pos
5611
- };
5612
5621
  }
5622
+ return {
5623
+ code: null,
5624
+ pos
5625
+ };
5613
5626
  }
5614
5627
  } else {
5615
5628
  ({
@@ -8176,20 +8189,26 @@ class ExpressionParser extends LValParser {
8176
8189
  } else {
8177
8190
  node.arguments = this.parseCallExpressionArguments(base.type !== "Super", node, refExpressionErrors);
8178
8191
  }
8179
- let finishedNode = this.finishCallExpression(node, optionalChainMember);
8180
- if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
8181
- state.stop = true;
8182
- this.checkDestructuringPrivate(refExpressionErrors);
8183
- this.expressionScope.validateAsPattern();
8184
- this.expressionScope.exit();
8185
- finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode);
8186
- } else {
8187
- if (maybeAsyncArrow) {
8188
- this.checkExpressionErrors(refExpressionErrors, true);
8192
+ const finishedNode = this.finishCallExpression(node, optionalChainMember);
8193
+ if (maybeAsyncArrow && !optional) {
8194
+ const errorsLength = this.state.errors.length;
8195
+ const asyncArrowHead = this.parseAsyncArrowHead(startLoc);
8196
+ if (asyncArrowHead) {
8197
+ const returnTypeErrors = this.state.errors.length > errorsLength ? this.state.errors.splice(errorsLength) : undefined;
8198
+ state.stop = true;
8199
+ this.checkDestructuringPrivate(refExpressionErrors);
8200
+ this.expressionScope.validateAsPattern();
8189
8201
  this.expressionScope.exit();
8202
+ if (returnTypeErrors) this.state.errors.push(...returnTypeErrors);
8203
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
8204
+ return this.parseAsyncArrowFromCallExpression(asyncArrowHead, finishedNode);
8190
8205
  }
8191
- this.toReferencedArguments(finishedNode);
8192
8206
  }
8207
+ if (maybeAsyncArrow) {
8208
+ this.checkExpressionErrors(refExpressionErrors, true);
8209
+ this.expressionScope.exit();
8210
+ }
8211
+ this.toReferencedArguments(finishedNode);
8193
8212
  this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
8194
8213
  return finishedNode;
8195
8214
  }
@@ -8238,12 +8257,13 @@ class ExpressionParser extends LValParser {
8238
8257
  break;
8239
8258
  }
8240
8259
  }
8241
- elts.push(this.parseExprListItem(11, false, refExpressionErrors, allowPlaceholder));
8260
+ const elt = this.parseExprListItem(11, false, refExpressionErrors, allowPlaceholder);
8261
+ if (elt !== null) elts.push(elt);
8242
8262
  }
8243
8263
  return elts;
8244
8264
  }
8245
- shouldParseAsyncArrow() {
8246
- return this.match(19) && !this.canInsertSemicolon();
8265
+ parseAsyncArrowHead(startLoc) {
8266
+ return this.match(19) && !this.canInsertSemicolon() ? this.startNodeAt(startLoc) : undefined;
8247
8267
  }
8248
8268
  parseAsyncArrowFromCallExpression(node, call) {
8249
8269
  var _call$extra;
@@ -8403,7 +8423,7 @@ class ExpressionParser extends LValParser {
8403
8423
  return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true);
8404
8424
  }
8405
8425
  if (tokenIsIdentifier(type)) {
8406
- if (this.isContextual(128) && this.lookaheadInLineCharCode() === 123) {
8426
+ if (this.isContextual(128) && this.state.start !== this.classHeritageStart && this.lookaheadInLineCharCode() === 123) {
8407
8427
  return this.parseModuleExpression();
8408
8428
  }
8409
8429
  const canBeArrow = this.state.potentialArrowAt === this.state.start;
@@ -8512,9 +8532,11 @@ class ExpressionParser extends LValParser {
8512
8532
  const oldLabels = this.state.labels;
8513
8533
  this.state.labels = [];
8514
8534
  if (isAsync) {
8535
+ this.expressionScope.enter(sharedExpressionScope);
8515
8536
  this.prodParam.enter(2);
8516
8537
  node.body = this.parseBlock();
8517
8538
  this.prodParam.exit();
8539
+ this.expressionScope.exit();
8518
8540
  } else {
8519
8541
  node.body = this.parseBlock();
8520
8542
  }
@@ -8576,7 +8598,7 @@ class ExpressionParser extends LValParser {
8576
8598
  parseImportMetaPropertyOrPhaseCall(node) {
8577
8599
  this.next();
8578
8600
  if (this.isContextual(106) || this.isContextual(98)) {
8579
- const isSource = this.isContextual(106);
8601
+ const isSource = this.match(106);
8580
8602
  this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation");
8581
8603
  this.next();
8582
8604
  node.phase = isSource ? "source" : "defer";
@@ -8721,7 +8743,9 @@ class ExpressionParser extends LValParser {
8721
8743
  }
8722
8744
  parseNewOrNewTarget() {
8723
8745
  const node = this.startNode();
8746
+ const isClassHeritageStart = this.state.start === this.classHeritageStart;
8724
8747
  this.next();
8748
+ if (isClassHeritageStart) this.classHeritageStart = this.state.start;
8725
8749
  if (this.match(16)) {
8726
8750
  const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
8727
8751
  this.next();
@@ -8736,7 +8760,7 @@ class ExpressionParser extends LValParser {
8736
8760
  parseNew(node) {
8737
8761
  this.parseNewCallee(node);
8738
8762
  if (this.eat(10)) {
8739
- const args = this.parseExprList(11);
8763
+ const args = this.parseExprList(11).filter(arg => arg !== null);
8740
8764
  this.toReferencedList(args);
8741
8765
  node.arguments = args;
8742
8766
  } else {
@@ -8868,15 +8892,12 @@ class ExpressionParser extends LValParser {
8868
8892
  const prop = this.startNodeAt(decoratorsStartLoc);
8869
8893
  let isAsync = false;
8870
8894
  let isAccessor = false;
8871
- let startLoc;
8872
8895
  if (decorators.length) {
8873
8896
  prop.decorators = decorators;
8874
8897
  decorators = [];
8875
8898
  }
8876
8899
  prop.method = false;
8877
- if (refExpressionErrors) {
8878
- startLoc = this.state.startLoc;
8879
- }
8900
+ const startLoc = this.state.startLoc;
8880
8901
  let isGenerator = this.eat(55);
8881
8902
  this.parsePropertyNamePrefixOperator(prop);
8882
8903
  const containsEsc = this.state.containsEsc;
@@ -9312,7 +9333,7 @@ class ExpressionParser extends LValParser {
9312
9333
  return this.finishNode(node, "YieldExpression");
9313
9334
  }
9314
9335
  parseImportCall(node) {
9315
- this.next();
9336
+ this.expect(10);
9316
9337
  node.source = this.parseMaybeAssignAllowIn();
9317
9338
  node.options = null;
9318
9339
  if (this.eat(12)) {
@@ -10288,6 +10309,7 @@ class StatementParser extends ExpressionParser {
10288
10309
  this.raise(Errors.LabelRedeclaration, expr, {
10289
10310
  labelName: maybeName
10290
10311
  });
10312
+ break;
10291
10313
  }
10292
10314
  }
10293
10315
  const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null;
@@ -10506,7 +10528,7 @@ class StatementParser extends ExpressionParser {
10506
10528
  return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
10507
10529
  }
10508
10530
  isClassProperty() {
10509
- return this.match(29) || this.match(13) || this.match(8);
10531
+ return this.match(29) || this.match(13) || this.match(8) || this.match(26) && this.hasPrecedingLineBreak();
10510
10532
  }
10511
10533
  isClassMethod() {
10512
10534
  return this.match(10);
@@ -10807,7 +10829,12 @@ class StatementParser extends ExpressionParser {
10807
10829
  }
10808
10830
  }
10809
10831
  parseClassSuper(node) {
10810
- node.superClass = this.eat(81) ? this.parseExprSubscripts() : null;
10832
+ if (this.eat(81)) {
10833
+ this.classHeritageStart = this.state.start;
10834
+ node.superClass = this.parseExprSubscripts();
10835
+ } else {
10836
+ node.superClass = null;
10837
+ }
10811
10838
  }
10812
10839
  parseExport(node, decorators) {
10813
10840
  const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
@@ -11055,7 +11082,8 @@ class StatementParser extends ExpressionParser {
11055
11082
  if (local.type !== "Identifier") {
11056
11083
  this.raise(Errors.ExportBindingIsString, specifier, {
11057
11084
  localName: local.value,
11058
- exportName
11085
+ exportName,
11086
+ typeModifierIn: node.exportKind === "type" ? "declaration" : specifier.exportKind === "type" ? "specifier" : undefined
11059
11087
  });
11060
11088
  } else {
11061
11089
  this.checkReservedWord(local.name, local.loc.start, true, false);
@@ -11608,6 +11636,40 @@ function tsIsTypeCast(node) {
11608
11636
  return false;
11609
11637
  }
11610
11638
  }
11639
+ function tsIsInvalidArrowParamsError(error, returnTypeStart) {
11640
+ if (error.pos >= returnTypeStart) return false;
11641
+ switch (error.reasonCode) {
11642
+ case "AwaitBindingIdentifier":
11643
+ case "AwaitExpressionFormalParameter":
11644
+ case "IllegalLanguageModeDirective":
11645
+ case "ParamDupe":
11646
+ case "StrictEvalArgumentsBinding":
11647
+ case "VarRedeclaration":
11648
+ case "YieldInParameter":
11649
+ return false;
11650
+ default:
11651
+ return true;
11652
+ }
11653
+ }
11654
+ function tsHasUnambiguousArrowParams(params) {
11655
+ var _first, _first2, _first3;
11656
+ if (!(params != null && params.length)) return true;
11657
+ let first = params[0];
11658
+ if (((_first = first) == null ? void 0 : _first.type) === "AssignmentPattern" || ((_first2 = first) == null ? void 0 : _first2.type) === "AssignmentExpression") {
11659
+ first = first.left;
11660
+ }
11661
+ switch ((_first3 = first) == null ? void 0 : _first3.type) {
11662
+ case "RestElement":
11663
+ case "SpreadElement":
11664
+ return true;
11665
+ case "TSTypeCastExpression":
11666
+ return first.expression.type === "Identifier" || first.expression.type === "ThisExpression";
11667
+ case "Identifier":
11668
+ return !!first.typeAnnotation || !!first.optional;
11669
+ default:
11670
+ return false;
11671
+ }
11672
+ }
11611
11673
  var typescript = superClass => class TypeScriptParserMixin extends superClass {
11612
11674
  constructor(...args) {
11613
11675
  super(...args);
@@ -11626,6 +11688,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
11626
11688
  disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"],
11627
11689
  errorTemplate: TSErrors.InvalidModifierOnTypeParameter
11628
11690
  });
11691
+ this.tsArrowReturnTypeAt = new Map();
11629
11692
  }
11630
11693
  getScopeHandler() {
11631
11694
  return TypeScriptScopeHandler;
@@ -12951,12 +13014,18 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
12951
13014
  node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
12952
13015
  super.parseFunctionParams(node);
12953
13016
  node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
13017
+ const arrowStartPos = this.offsetToSourcePos(startLoc.index);
13018
+ if (node.returnType && this.match(19) && this.tsIsArrowReturnTypeRestrictedAt(arrowStartPos)) {
13019
+ this.tsArrowReturnTypeAt.set(arrowStartPos, node.returnType.start);
13020
+ }
12954
13021
  this.expect(19);
12955
13022
  return node;
12956
13023
  });
12957
13024
  this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
12958
13025
  if (!res) return;
12959
- return super.parseArrowExpression(res, null, true);
13026
+ const startPos = this.offsetToSourcePos(startLoc.index);
13027
+ const parse = () => res.returnType && this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithDeferredArrowErrors(() => super.parseArrowExpression(res, null, true)) : super.parseArrowExpression(res, null, true);
13028
+ return this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithRestrictedArrowReturnType(parse, this.hasPlugin("jsx") || this.state.tsArrowReturnTypeAllowed) : parse();
12960
13029
  }
12961
13030
  tsParseTypeArgumentsInExpression() {
12962
13031
  if (this.reScan_lt() !== 47) return;
@@ -13094,7 +13163,8 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13094
13163
  }
13095
13164
  if (this.match(47) || this.match(51)) {
13096
13165
  let missingParenErrorLoc;
13097
- const result = this.tsTryParseAndCatch(() => {
13166
+ let parsingAsyncArrow = true;
13167
+ const parseAttempt = () => {
13098
13168
  if (!noCalls && this.atPossibleAsyncArrow(base)) {
13099
13169
  const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc);
13100
13170
  if (asyncArrowFn) {
@@ -13102,6 +13172,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13102
13172
  return asyncArrowFn;
13103
13173
  }
13104
13174
  }
13175
+ parsingAsyncArrow = false;
13105
13176
  const typeArguments = this.tsParseTypeArgumentsInExpression();
13106
13177
  if (!typeArguments) return;
13107
13178
  if (isOptionalCall && !this.match(10)) {
@@ -13132,7 +13203,13 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13132
13203
  node.expression = base;
13133
13204
  node.typeParameters = typeArguments;
13134
13205
  return this.finishNode(node, "TSInstantiationExpression");
13135
- });
13206
+ };
13207
+ const attempt = this.tryParse(abort => parseAttempt() || abort());
13208
+ if (attempt.thrown && parsingAsyncArrow && this.tsShouldKeepArrowErrorAt(attempt.error, this.offsetToSourcePos(startLoc.index))) {
13209
+ throw attempt.error;
13210
+ }
13211
+ const result = attempt.node;
13212
+ if (result && attempt.error) this.state = attempt.failState;
13136
13213
  if (missingParenErrorLoc) {
13137
13214
  this.unexpected(missingParenErrorLoc, 10);
13138
13215
  }
@@ -13479,17 +13556,36 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13479
13556
  return expr;
13480
13557
  }
13481
13558
  }
13559
+ const startPos = this.offsetToSourcePos(startLoc.index);
13560
+ const isRestricted = this.tsIsArrowReturnTypeRestrictedAt(startPos);
13561
+ const allowsReturnType = isRestricted && this.state.tsArrowReturnTypeAllowed;
13482
13562
  this.next();
13483
13563
  const node = this.startNodeAt(startLoc);
13484
13564
  node.test = expr;
13485
- const oldInConditionalConsequent = this.state.inConditionalConsequent;
13486
- this.state.inConditionalConsequent = true;
13487
- node.consequent = this.parseMaybeAssignAllowIn();
13488
- this.state.inConditionalConsequent = oldInConditionalConsequent;
13565
+ node.consequent = this.tsParseWithRestrictedArrowReturnType(() => this.parseMaybeAssignAllowIn());
13489
13566
  this.expect(14);
13490
- node.alternate = this.parseMaybeAssign();
13567
+ node.alternate = isRestricted ? this.tsParseWithRestrictedArrowReturnType(() => this.parseMaybeAssign(), allowsReturnType) : this.parseMaybeAssign();
13491
13568
  return this.finishNode(node, "ConditionalExpression");
13492
13569
  }
13570
+ tsIsArrowReturnTypeRestrictedAt(sourcePos) {
13571
+ return this.state.tsArrowReturnTypeRestrictionAt === sourcePos;
13572
+ }
13573
+ tsRestrictArrowReturnTypeAt(sourcePos, allowsReturnType, genericParams = false) {
13574
+ this.state.tsArrowReturnTypeRestrictionAt = sourcePos;
13575
+ this.state.tsArrowReturnTypeAllowed = allowsReturnType;
13576
+ this.state.tsGenericArrowParams = genericParams;
13577
+ }
13578
+ tsParseWithRestrictedArrowReturnType(parse, allowsReturnType = false, genericParams = false) {
13579
+ const oldAllowed = this.state.tsArrowReturnTypeAllowed;
13580
+ const oldGeneric = this.state.tsGenericArrowParams;
13581
+ const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
13582
+ this.tsRestrictArrowReturnTypeAt(this.state.start, allowsReturnType, genericParams);
13583
+ const result = parse();
13584
+ this.state.tsArrowReturnTypeRestrictionAt = oldStart;
13585
+ this.state.tsArrowReturnTypeAllowed = oldAllowed;
13586
+ this.state.tsGenericArrowParams = oldGeneric;
13587
+ return result;
13588
+ }
13493
13589
  parseParenItem(node, startLoc) {
13494
13590
  const newNode = super.parseParenItem(node, startLoc);
13495
13591
  if (this.eat(17)) {
@@ -13647,13 +13743,82 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13647
13743
  this.resetEndLocation(decl.id);
13648
13744
  }
13649
13745
  }
13650
- parseAsyncArrowFromCallExpression(node, call) {
13651
- if (this.match(14)) {
13652
- node.returnType = this.tsParseTypeAnnotation();
13746
+ parseMaybeAssign(refExpressionErrors, afterLeftParse) {
13747
+ const startPos = this.state.start;
13748
+ if (!this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
13749
+ return this.tsParseMaybeAssign(refExpressionErrors, afterLeftParse);
13750
+ }
13751
+ const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
13752
+ const oldAllowed = this.state.tsArrowReturnTypeAllowed;
13753
+ const oldGeneric = this.state.tsGenericArrowParams;
13754
+ const node = this.match(10) || this.match(47) || this.isContextual(96) ? this.tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, afterLeftParse) : this.tsParseMaybeAssign(refExpressionErrors, afterLeftParse);
13755
+ this.state.tsArrowReturnTypeRestrictionAt = oldStart;
13756
+ this.state.tsArrowReturnTypeAllowed = oldAllowed;
13757
+ this.state.tsGenericArrowParams = oldGeneric;
13758
+ return node;
13759
+ }
13760
+ tsParseWithDeferredArrowErrors(parse) {
13761
+ if (this.optionFlags & 2048) return parse();
13762
+ this.optionFlags |= 2048;
13763
+ try {
13764
+ return parse();
13765
+ } finally {
13766
+ this.optionFlags &= ~2048;
13653
13767
  }
13654
- return super.parseAsyncArrowFromCallExpression(node, call);
13655
13768
  }
13656
- parseMaybeAssign(refExpressionErrors, afterLeftParse) {
13769
+ tsShouldKeepArrowErrorAt(error, startPos) {
13770
+ if (!this.tsIsArrowReturnTypeRestrictedAt(startPos)) return false;
13771
+ const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
13772
+ return returnTypeStart !== undefined && !tsIsInvalidArrowParamsError(error, returnTypeStart);
13773
+ }
13774
+ tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, afterLeftParse) {
13775
+ if (!this.noArrowAt.has(startPos)) {
13776
+ const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
13777
+ const parse = () => this.tsParseMaybeAssign(refExpressionErrors, afterLeftParse);
13778
+ let state = this.state.clone();
13779
+ const {
13780
+ tokensLength
13781
+ } = state;
13782
+ this.tsArrowReturnTypeAt.delete(startPos);
13783
+ let result = this.tryParse(parse, state);
13784
+ const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
13785
+ if (result.thrown && returnTypeStart !== undefined && !tsIsInvalidArrowParamsError(result.error, returnTypeStart) && !(this.optionFlags & 2048)) {
13786
+ state = this.state.clone();
13787
+ this.optionFlags |= 2048;
13788
+ try {
13789
+ result = this.tryParse(parse, state);
13790
+ } finally {
13791
+ this.optionFlags &= ~2048;
13792
+ }
13793
+ }
13794
+ if (result.thrown) {
13795
+ if (!this.tsArrowReturnTypeAt.has(startPos)) throw result.error;
13796
+ } else {
13797
+ var _node$extra2;
13798
+ if (result.error) this.state = result.failState;
13799
+ const node = result.node;
13800
+ if (node.type !== "ArrowFunctionExpression" || !node.returnType || (_node$extra2 = node.extra) != null && _node$extra2.parenthesized) {
13801
+ return node;
13802
+ }
13803
+ const {
13804
+ start
13805
+ } = node.returnType;
13806
+ const hasInvalidParams = result.error != null && this.state.errors.slice(state.errors.length).some(error => tsIsInvalidArrowParamsError(error, start));
13807
+ const isUnambiguous = node.typeParameters ? this.hasPlugin("jsx") : tsHasUnambiguousArrowParams(node.params);
13808
+ if (!hasInvalidParams && (allowsReturnType || this.match(14)) || isUnambiguous && !(hasInvalidParams && node.async)) {
13809
+ if (result.error && !(this.optionFlags & 2048)) {
13810
+ throw result.error;
13811
+ }
13812
+ return node;
13813
+ }
13814
+ }
13815
+ this.noArrowAt.add(startPos);
13816
+ this.state = state;
13817
+ this.state.tokensLength = tokensLength;
13818
+ }
13819
+ return this.tsParseMaybeAssign(refExpressionErrors, afterLeftParse);
13820
+ }
13821
+ tsParseMaybeAssign(refExpressionErrors, afterLeftParse) {
13657
13822
  var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2;
13658
13823
  let state;
13659
13824
  let jsx;
@@ -13677,8 +13842,26 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13677
13842
  let typeParameters;
13678
13843
  const arrow = this.tryParse(abort => {
13679
13844
  var _expr$extra, _typeParameters;
13845
+ const startPos = this.state.start;
13846
+ if (this.noArrowAt.has(startPos)) abort();
13847
+ const allowsReturnType = !this.match(47) || this.state.tsArrowReturnTypeAllowed;
13848
+ const isRestricted = this.tsIsArrowReturnTypeRestrictedAt(startPos);
13680
13849
  typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier);
13681
- const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
13850
+ let expr;
13851
+ if (isRestricted) {
13852
+ const paramsStartPos = this.state.start;
13853
+ this.tsArrowReturnTypeAt.delete(paramsStartPos);
13854
+ try {
13855
+ expr = this.tsParseWithRestrictedArrowReturnType(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), allowsReturnType, true);
13856
+ } finally {
13857
+ const returnTypeStart = this.tsArrowReturnTypeAt.get(paramsStartPos);
13858
+ if (returnTypeStart !== undefined) {
13859
+ this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
13860
+ }
13861
+ }
13862
+ } else {
13863
+ expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse);
13864
+ }
13682
13865
  if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) {
13683
13866
  abort();
13684
13867
  }
@@ -13688,6 +13871,15 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13688
13871
  expr.typeParameters = typeParameters;
13689
13872
  return expr;
13690
13873
  }, state);
13874
+ if (jsx && arrow.node && arrow.error && !(this.optionFlags & 2048)) {
13875
+ throw arrow.error;
13876
+ }
13877
+ if (arrow.error && this.tsShouldKeepArrowErrorAt(arrow.error, state.start)) {
13878
+ if (!arrow.node) throw arrow.error;
13879
+ this.state = arrow.failState;
13880
+ if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
13881
+ return arrow.node;
13882
+ }
13691
13883
  if (!arrow.error && !arrow.aborted) {
13692
13884
  if (typeParameters) this.reportReservedArrowTypeParam(typeParameters);
13693
13885
  return arrow.node;
@@ -13713,8 +13905,8 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13713
13905
  throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error);
13714
13906
  }
13715
13907
  reportReservedArrowTypeParam(node) {
13716
- var _node$extra2;
13717
- if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra2 = node.extra) != null && _node$extra2.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
13908
+ var _node$extra3;
13909
+ if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra3 = node.extra) != null && _node$extra3.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) {
13718
13910
  this.raise(TSErrors.ReservedArrowTypeParam, node);
13719
13911
  }
13720
13912
  }
@@ -13726,6 +13918,9 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13726
13918
  }
13727
13919
  parseArrow(node) {
13728
13920
  if (this.match(14)) {
13921
+ const startPos = this.offsetToSourcePos(node.start);
13922
+ if (this.noArrowAt.has(startPos)) return;
13923
+ const returnTypeStart = this.sourceToOffsetPos(this.state.start);
13729
13924
  const result = this.tryParse(abort => {
13730
13925
  const returnType = this.tsParseTypeOrTypePredicateAnnotation(14);
13731
13926
  if (this.canInsertSemicolon() || !this.match(19)) abort();
@@ -13735,6 +13930,9 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13735
13930
  if (!result.thrown) {
13736
13931
  if (result.error) this.state = result.failState;
13737
13932
  node.returnType = result.node;
13933
+ if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
13934
+ this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
13935
+ }
13738
13936
  }
13739
13937
  }
13740
13938
  return super.parseArrow(node);
@@ -13902,19 +14100,46 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
13902
14100
  }
13903
14101
  return super.shouldParseArrow(params);
13904
14102
  }
13905
- shouldParseAsyncArrow() {
13906
- if (this.match(14)) {
13907
- if (this.state.inConditionalConsequent) return false;
13908
- return true;
14103
+ parseAsyncArrowHead(startLoc) {
14104
+ if (!this.match(14)) return super.parseAsyncArrowHead(startLoc);
14105
+ const returnTypeStart = this.sourceToOffsetPos(this.state.start);
14106
+ const result = this.tryParse(abort => {
14107
+ const returnType = this.tsParseTypeAnnotation();
14108
+ if (!this.match(19)) abort();
14109
+ return returnType;
14110
+ });
14111
+ if (result.aborted || result.thrown) return undefined;
14112
+ if (result.error) this.state = result.failState;
14113
+ const startPos = this.offsetToSourcePos(startLoc.index);
14114
+ if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
14115
+ this.tsArrowReturnTypeAt.set(startPos, returnTypeStart);
13909
14116
  }
13910
- return super.shouldParseAsyncArrow();
14117
+ const node = this.startNodeAt(startLoc);
14118
+ node.returnType = result.node;
14119
+ return node;
13911
14120
  }
13912
- parseParenAndDistinguishExpression(canBeArrow) {
13913
- const oldInConditionalConsequent = this.state.inConditionalConsequent;
13914
- this.state.inConditionalConsequent = false;
13915
- const result = super.parseParenAndDistinguishExpression(canBeArrow);
13916
- this.state.inConditionalConsequent = oldInConditionalConsequent;
13917
- return result;
14121
+ atPossibleAsyncArrow(base) {
14122
+ return super.atPossibleAsyncArrow(base) && !this.noArrowAt.has(this.offsetToSourcePos(base.start));
14123
+ }
14124
+ parseMaybeConditional(refExpressionErrors) {
14125
+ if (!this.tsIsArrowReturnTypeRestrictedAt(this.state.start)) {
14126
+ return super.parseMaybeConditional(refExpressionErrors);
14127
+ }
14128
+ const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
14129
+ const expr = super.parseMaybeConditional(refExpressionErrors);
14130
+ if (tokenIsAssignment(this.state.type)) {
14131
+ this.tsRestrictArrowReturnTypeAt(this.nextTokenStart(), allowsReturnType);
14132
+ }
14133
+ return expr;
14134
+ }
14135
+ parseArrowExpression(node, params, isAsync, trailingCommaLoc) {
14136
+ const startPos = this.offsetToSourcePos(node.start);
14137
+ if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
14138
+ const genericParams = this.state.tsGenericArrowParams;
14139
+ const parse = () => super.parseArrowExpression(node, params, isAsync, trailingCommaLoc);
14140
+ return this.tsParseWithRestrictedArrowReturnType(genericParams && node.returnType ? () => this.tsParseWithDeferredArrowErrors(parse) : parse, this.state.tsArrowReturnTypeAllowed || !genericParams && tsHasUnambiguousArrowParams(params));
14141
+ }
14142
+ return super.parseArrowExpression(node, params, isAsync, trailingCommaLoc);
13918
14143
  }
13919
14144
  canHaveLeadingDecorator() {
13920
14145
  return super.canHaveLeadingDecorator() || this.isAbstractClass();
@@ -14045,7 +14270,7 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
14045
14270
  const firstAs = this.parseIdentifier();
14046
14271
  if (this.isContextual(94)) {
14047
14272
  const secondAs = this.parseIdentifier();
14048
- if (tokenIsKeywordOrIdentifier(this.state.type)) {
14273
+ if (isImport ? tokenIsKeywordOrIdentifier(this.state.type) : this.tsIsStartOfModuleExportName()) {
14049
14274
  hasTypeSpecifier = true;
14050
14275
  leftOfAs = firstAs;
14051
14276
  rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
@@ -14054,16 +14279,16 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
14054
14279
  rightOfAs = secondAs;
14055
14280
  canParseAsKeyword = false;
14056
14281
  }
14057
- } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14282
+ } else if (isImport ? tokenIsKeywordOrIdentifier(this.state.type) : this.tsIsStartOfModuleExportName()) {
14058
14283
  canParseAsKeyword = false;
14059
14284
  rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName();
14060
14285
  } else {
14061
14286
  hasTypeSpecifier = true;
14062
14287
  leftOfAs = firstAs;
14063
14288
  }
14064
- } else if (tokenIsKeywordOrIdentifier(this.state.type)) {
14289
+ } else if (this.tsIsStartOfModuleExportName()) {
14065
14290
  hasTypeSpecifier = true;
14066
- if (isImport) {
14291
+ if (isImport && !this.match(135)) {
14067
14292
  leftOfAs = this.parseIdentifier(true);
14068
14293
  if (!this.isContextual(94)) {
14069
14294
  this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true);
@@ -14083,12 +14308,20 @@ var typescript = superClass => class TypeScriptParserMixin extends superClass {
14083
14308
  node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName();
14084
14309
  }
14085
14310
  if (!node[rightOfAsKey]) {
14086
- node[rightOfAsKey] = this.cloneIdentifier(node[leftOfAsKey]);
14311
+ if (isImport && node[leftOfAsKey].type !== "Identifier") {
14312
+ throw this.raise(Errors.ImportBindingIsString, node, {
14313
+ importName: node[leftOfAsKey].value
14314
+ });
14315
+ }
14316
+ node[rightOfAsKey] = node[leftOfAsKey].type !== "Identifier" ? this.cloneStringLiteral(node[leftOfAsKey]) : this.cloneIdentifier(node[leftOfAsKey]);
14087
14317
  }
14088
14318
  if (isImport) {
14089
14319
  this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096);
14090
14320
  }
14091
14321
  }
14322
+ tsIsStartOfModuleExportName() {
14323
+ return tokenIsKeywordOrIdentifier(this.state.type) || this.match(135);
14324
+ }
14092
14325
  fillOptionalPropertiesForTSESLint(node) {
14093
14326
  var _node$phase, _node$directive, _node$decorators, _node$optional, _node$typeAnnotation, _node$accessibility, _node$decorators2, _node$override, _node$readonly, _node$static, _node$declare, _node$returnType, _node$typeParameters, _node$optional2, _node$optional3, _node$accessibility2, _node$readonly2, _node$static2, _node$declare2, _node$definite, _node$readonly3, _node$typeAnnotation2, _node$accessibility3, _node$decorators3, _node$override2, _node$optional4, _node$id, _node$abstract, _node$declare3, _node$decorators4, _node$implements, _node$superTypeArgume, _node$typeParameters2, _node$declare4, _node$definite2, _node$const, _node$declare5, _node$computed, _node$qualifier, _node$options, _node$declare6, _node$extends, _node$optional5, _node$readonly4, _node$declare7, _node$global, _node$const2, _node$in, _node$out;
14094
14327
  switch (node.type) {
@@ -14473,7 +14706,9 @@ var placeholders = superClass => class PlaceholdersParserMixin extends superClas
14473
14706
  node.specifiers = [];
14474
14707
  if (!this.isContextual(99) && !this.match(12)) {
14475
14708
  node.source = this.finishPlaceholder(placeholder, "StringLiteral");
14709
+ this.maybeParseImportAttributes(node);
14476
14710
  this.semicolon();
14711
+ this.sawUnambiguousESM = true;
14477
14712
  return this.finishNode(node, "ImportDeclaration");
14478
14713
  }
14479
14714
  const specifier = this.startNodeAtNode(placeholder);
@@ -14484,9 +14719,7 @@ var placeholders = superClass => class PlaceholdersParserMixin extends superClas
14484
14719
  if (!hasStarImport) this.parseNamedImportSpecifiers(node);
14485
14720
  }
14486
14721
  this.expectContextual(99);
14487
- node.source = this.parseImportSource();
14488
- this.semicolon();
14489
- return this.finishNode(node, "ImportDeclaration");
14722
+ return super.parseImportSourceAndAttributes(node);
14490
14723
  }
14491
14724
  parseImportSource() {
14492
14725
  return this.parsePlaceholder("StringLiteral") || super.parseImportSource();