typescript 5.5.0-dev.20240528 → 5.5.0-dev.20240530

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 (3) hide show
  1. package/lib/tsc.js +170 -124
  2. package/lib/typescript.js +178 -125
  3. package/package.json +11 -11
package/lib/typescript.js CHANGED
@@ -2370,7 +2370,7 @@ module.exports = __toCommonJS(typescript_exports);
2370
2370
 
2371
2371
  // src/compiler/corePublic.ts
2372
2372
  var versionMajorMinor = "5.5";
2373
- var version = `${versionMajorMinor}.0-dev.20240528`;
2373
+ var version = `${versionMajorMinor}.0-dev.20240530`;
2374
2374
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2375
2375
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2376
2376
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9700,8 +9700,10 @@ var Diagnostics = {
9700
9700
  _0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces: diag(1531, 1 /* Error */, "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1531", "'\\{0}' must be followed by a Unicode property value expression enclosed in braces."),
9701
9701
  There_is_no_capturing_group_named_0_in_this_regular_expression: diag(1532, 1 /* Error */, "There_is_no_capturing_group_named_0_in_this_regular_expression_1532", "There is no capturing group named '{0}' in this regular expression."),
9702
9702
  This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1533, 1 /* Error */, "This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_r_1533", "This backreference refers to a group that does not exist. There are only {0} capturing groups in this regular expression."),
9703
- This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups: diag(1534, 1 /* Error */, "This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups_1534", "This backreference is invalid because the containing regular expression contains no capturing groups."),
9703
+ This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression: diag(1534, 1 /* Error */, "This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regul_1534", "This backreference refers to a group that does not exist. There are no capturing groups in this regular expression."),
9704
9704
  This_character_cannot_be_escaped_in_a_regular_expression: diag(1535, 1 /* Error */, "This_character_cannot_be_escaped_in_a_regular_expression_1535", "This character cannot be escaped in a regular expression."),
9705
+ Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended_as_an_escape_sequence_use_the_syntax_0_instead: diag(1536, 1 /* Error */, "Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended__1536", "Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '{0}' instead."),
9706
+ Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class: diag(1537, 1 /* Error */, "Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_1537", "Decimal escape sequences and backreferences are not allowed in a character class."),
9705
9707
  The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
9706
9708
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
9707
9709
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -12445,12 +12447,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12445
12447
  }
12446
12448
  if (ch === 92 /* backslash */ && !jsxAttributeString) {
12447
12449
  result += text.substring(start2, pos);
12448
- result += scanEscapeSequence(
12449
- /*shouldEmitInvalidEscapeError*/
12450
- true,
12451
- /*isRegularExpression*/
12452
- false
12453
- );
12450
+ result += scanEscapeSequence(1 /* String */ | 2 /* ReportErrors */);
12454
12451
  start2 = pos;
12455
12452
  continue;
12456
12453
  }
@@ -12493,11 +12490,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12493
12490
  }
12494
12491
  if (currChar === 92 /* backslash */) {
12495
12492
  contents += text.substring(start2, pos);
12496
- contents += scanEscapeSequence(
12497
- shouldEmitInvalidEscapeError,
12498
- /*isRegularExpression*/
12499
- false
12500
- );
12493
+ contents += scanEscapeSequence(1 /* String */ | (shouldEmitInvalidEscapeError ? 2 /* ReportErrors */ : 0));
12501
12494
  start2 = pos;
12502
12495
  continue;
12503
12496
  }
@@ -12517,7 +12510,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12517
12510
  tokenValue = contents;
12518
12511
  return resultingToken;
12519
12512
  }
12520
- function scanEscapeSequence(shouldEmitInvalidEscapeError, isRegularExpression) {
12513
+ function scanEscapeSequence(flags) {
12521
12514
  const start2 = pos;
12522
12515
  pos++;
12523
12516
  if (pos >= end) {
@@ -12545,9 +12538,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12545
12538
  pos++;
12546
12539
  }
12547
12540
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12548
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
12541
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
12549
12542
  const code = parseInt(text.substring(start2 + 1, pos), 8);
12550
- if (isRegularExpression !== "annex-b") {
12543
+ if (flags & 4 /* RegularExpression */ && !(flags & 32 /* AtomEscape */) && ch !== 48 /* _0 */) {
12544
+ error2(Diagnostics.Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended_as_an_escape_sequence_use_the_syntax_0_instead, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
12545
+ } else {
12551
12546
  error2(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
12552
12547
  }
12553
12548
  return String.fromCharCode(code);
@@ -12556,8 +12551,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12556
12551
  case 56 /* _8 */:
12557
12552
  case 57 /* _9 */:
12558
12553
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12559
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
12560
- error2(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
12554
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
12555
+ if (flags & 4 /* RegularExpression */ && !(flags & 32 /* AtomEscape */)) {
12556
+ error2(Diagnostics.Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class, start2, pos - start2);
12557
+ } else {
12558
+ error2(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
12559
+ }
12561
12560
  return String.fromCharCode(ch);
12562
12561
  }
12563
12562
  return text.substring(start2, pos);
@@ -12578,14 +12577,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12578
12577
  case 34 /* doubleQuote */:
12579
12578
  return '"';
12580
12579
  case 117 /* u */:
12581
- if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
12580
+ if (flags & 17 /* ScanExtendedUnicodeEscape */ && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
12582
12581
  pos -= 2;
12583
- return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
12582
+ return scanExtendedUnicodeEscape(!!(flags & 6 /* ReportInvalidEscapeErrors */));
12584
12583
  }
12585
12584
  for (; pos < start2 + 6; pos++) {
12586
12585
  if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
12587
12586
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12588
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
12587
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
12589
12588
  error2(Diagnostics.Hexadecimal_digit_expected);
12590
12589
  }
12591
12590
  return text.substring(start2, pos);
@@ -12594,7 +12593,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12594
12593
  tokenFlags |= 1024 /* UnicodeEscape */;
12595
12594
  const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
12596
12595
  const escapedValueString = String.fromCharCode(escapedValue);
12597
- if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
12596
+ if (flags & 16 /* AnyUnicodeMode */ && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
12598
12597
  const nextStart = pos;
12599
12598
  let nextPos = pos + 2;
12600
12599
  for (; nextPos < nextStart + 6; nextPos++) {
@@ -12613,7 +12612,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12613
12612
  for (; pos < start2 + 4; pos++) {
12614
12613
  if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
12615
12614
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12616
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
12615
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
12617
12616
  error2(Diagnostics.Hexadecimal_digit_expected);
12618
12617
  }
12619
12618
  return text.substring(start2, pos);
@@ -12630,7 +12629,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12630
12629
  case 8233 /* paragraphSeparator */:
12631
12630
  return "";
12632
12631
  default:
12633
- if (isRegularExpression === true && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
12632
+ if (flags & 16 /* AnyUnicodeMode */ || flags & 4 /* RegularExpression */ && !(flags & 8 /* AnnexB */) && isIdentifierPart(ch, languageVersion)) {
12634
12633
  error2(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2);
12635
12634
  }
12636
12635
  return String.fromCharCode(ch);
@@ -13329,6 +13328,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13329
13328
  const startOfRegExpBody = tokenStart + 1;
13330
13329
  pos = startOfRegExpBody;
13331
13330
  let inEscape = false;
13331
+ let namedCaptureGroups = false;
13332
13332
  let inCharacterClass = false;
13333
13333
  while (true) {
13334
13334
  const ch = charCodeChecked(pos);
@@ -13346,6 +13346,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13346
13346
  inEscape = true;
13347
13347
  } else if (ch === 93 /* closeBracket */) {
13348
13348
  inCharacterClass = false;
13349
+ } else if (!inCharacterClass && ch === 40 /* openParen */ && charCodeChecked(pos + 1) === 63 /* question */ && charCodeChecked(pos + 2) === 60 /* lessThan */ && charCodeChecked(pos + 3) !== 61 /* equals */ && charCodeChecked(pos + 3) !== 33 /* exclamation */) {
13350
+ namedCaptureGroups = true;
13349
13351
  }
13350
13352
  pos++;
13351
13353
  }
@@ -13413,7 +13415,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13413
13415
  scanRegularExpressionWorker(
13414
13416
  regExpFlags,
13415
13417
  /*annexB*/
13416
- true
13418
+ true,
13419
+ namedCaptureGroups
13417
13420
  );
13418
13421
  });
13419
13422
  }
@@ -13423,12 +13426,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13423
13426
  }
13424
13427
  return token;
13425
13428
  }
13426
- function scanRegularExpressionWorker(regExpFlags, annexB) {
13429
+ function scanRegularExpressionWorker(regExpFlags, annexB, namedCaptureGroups) {
13427
13430
  var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
13428
13431
  var anyUnicodeMode = !!(regExpFlags & 96 /* AnyUnicodeMode */);
13429
- if (anyUnicodeMode) {
13430
- annexB = false;
13431
- }
13432
+ var anyUnicodeModeOrNonAnnexB = anyUnicodeMode || !annexB;
13432
13433
  var mayContainStrings = false;
13433
13434
  var numberOfCapturingGroups = 0;
13434
13435
  var groupSpecifiers;
@@ -13483,7 +13484,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13483
13484
  case 61 /* equals */:
13484
13485
  case 33 /* exclamation */:
13485
13486
  pos++;
13486
- isPreviousTermQuantifiable = annexB;
13487
+ isPreviousTermQuantifiable = !anyUnicodeModeOrNonAnnexB;
13487
13488
  break;
13488
13489
  case 60 /* lessThan */:
13489
13490
  const groupNameStart = pos;
@@ -13537,6 +13538,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13537
13538
  const digitsStart = pos;
13538
13539
  scanDigits();
13539
13540
  const min2 = tokenValue;
13541
+ if (!anyUnicodeModeOrNonAnnexB && !min2) {
13542
+ isPreviousTermQuantifiable = true;
13543
+ break;
13544
+ }
13540
13545
  if (charCodeChecked(pos) === 44 /* comma */) {
13541
13546
  pos++;
13542
13547
  scanDigits();
@@ -13545,25 +13550,29 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13545
13550
  if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
13546
13551
  error2(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
13547
13552
  } else {
13548
- if (anyUnicodeMode) {
13549
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13550
- }
13553
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13551
13554
  isPreviousTermQuantifiable = true;
13552
13555
  break;
13553
13556
  }
13554
- }
13555
- if (max && Number.parseInt(min2) > Number.parseInt(max)) {
13557
+ } else if (max && Number.parseInt(min2) > Number.parseInt(max) && (anyUnicodeModeOrNonAnnexB || charCodeChecked(pos) === 125 /* closeBrace */)) {
13556
13558
  error2(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
13557
13559
  }
13558
13560
  } else if (!min2) {
13559
- if (anyUnicodeMode) {
13561
+ if (anyUnicodeModeOrNonAnnexB) {
13560
13562
  error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13561
13563
  }
13562
13564
  isPreviousTermQuantifiable = true;
13563
13565
  break;
13564
13566
  }
13565
- scanExpectedChar(125 /* closeBrace */);
13566
- pos--;
13567
+ if (charCodeChecked(pos) !== 125 /* closeBrace */) {
13568
+ if (anyUnicodeModeOrNonAnnexB) {
13569
+ error2(Diagnostics._0_expected, pos, 0, String.fromCharCode(125 /* closeBrace */));
13570
+ pos--;
13571
+ } else {
13572
+ isPreviousTermQuantifiable = true;
13573
+ break;
13574
+ }
13575
+ }
13567
13576
  case 42 /* asterisk */:
13568
13577
  case 43 /* plus */:
13569
13578
  case 63 /* question */:
@@ -13596,7 +13605,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13596
13605
  }
13597
13606
  case 93 /* closeBracket */:
13598
13607
  case 125 /* closeBrace */:
13599
- if (anyUnicodeMode || ch === 41 /* closeParen */) {
13608
+ if (anyUnicodeModeOrNonAnnexB || ch === 41 /* closeParen */) {
13600
13609
  error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
13601
13610
  }
13602
13611
  pos++;
@@ -13645,7 +13654,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13645
13654
  true
13646
13655
  );
13647
13656
  scanExpectedChar(62 /* greaterThan */);
13648
- } else if (anyUnicodeMode) {
13657
+ } else if (anyUnicodeModeOrNonAnnexB || namedCaptureGroups) {
13649
13658
  error2(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
13650
13659
  }
13651
13660
  break;
@@ -13688,9 +13697,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13688
13697
  pos++;
13689
13698
  return String.fromCharCode(ch & 31);
13690
13699
  }
13691
- if (anyUnicodeMode) {
13700
+ if (anyUnicodeModeOrNonAnnexB) {
13692
13701
  error2(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
13693
- } else if (atomEscape && annexB) {
13702
+ } else if (atomEscape) {
13694
13703
  pos--;
13695
13704
  return "\\";
13696
13705
  }
@@ -13715,10 +13724,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13715
13724
  default:
13716
13725
  pos--;
13717
13726
  return scanEscapeSequence(
13718
- /*shouldEmitInvalidEscapeError*/
13719
- anyUnicodeMode,
13720
- /*isRegularExpression*/
13721
- annexB ? "annex-b" : true
13727
+ 4 /* RegularExpression */ | (annexB ? 8 /* AnnexB */ : 0) | (anyUnicodeMode ? 16 /* AnyUnicodeMode */ : 0) | (atomEscape ? 32 /* AtomEscape */ : 0)
13722
13728
  );
13723
13729
  }
13724
13730
  }
@@ -13760,12 +13766,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13760
13766
  if (isClassContentExit(ch2)) {
13761
13767
  return;
13762
13768
  }
13763
- if (!minCharacter && !annexB) {
13769
+ if (!minCharacter && anyUnicodeModeOrNonAnnexB) {
13764
13770
  error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
13765
13771
  }
13766
13772
  const maxStart = pos;
13767
13773
  const maxCharacter = scanClassAtom();
13768
- if (!maxCharacter && !annexB) {
13774
+ if (!maxCharacter && anyUnicodeModeOrNonAnnexB) {
13769
13775
  error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
13770
13776
  continue;
13771
13777
  }
@@ -14195,8 +14201,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14195
14201
  if (!anyUnicodeMode) {
14196
14202
  error2(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
14197
14203
  }
14198
- } else if (anyUnicodeMode) {
14204
+ } else if (anyUnicodeModeOrNonAnnexB) {
14199
14205
  error2(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
14206
+ } else {
14207
+ pos--;
14208
+ return false;
14200
14209
  }
14201
14210
  return true;
14202
14211
  }
@@ -14236,11 +14245,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14236
14245
  }
14237
14246
  });
14238
14247
  forEach(decimalEscapes, (escape) => {
14239
- if (!annexB && escape.value > numberOfCapturingGroups) {
14248
+ if (escape.value > numberOfCapturingGroups) {
14240
14249
  if (numberOfCapturingGroups) {
14241
14250
  error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
14242
14251
  } else {
14243
- error2(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
14252
+ error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos);
14244
14253
  }
14245
14254
  }
14246
14255
  });
@@ -29801,7 +29810,7 @@ var addDisposableResourceHelper = {
29801
29810
  var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
29802
29811
  if (value !== null && value !== void 0) {
29803
29812
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
29804
- var dispose;
29813
+ var dispose, inner;
29805
29814
  if (async) {
29806
29815
  if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
29807
29816
  dispose = value[Symbol.asyncDispose];
@@ -29809,8 +29818,10 @@ var addDisposableResourceHelper = {
29809
29818
  if (dispose === void 0) {
29810
29819
  if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
29811
29820
  dispose = value[Symbol.dispose];
29821
+ if (async) inner = dispose;
29812
29822
  }
29813
29823
  if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
29824
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
29814
29825
  env.stack.push({ value: value, dispose: dispose, async: async });
29815
29826
  }
29816
29827
  else if (async) {
@@ -49827,9 +49838,6 @@ function createTypeChecker(host) {
49827
49838
  deferredDiagnosticsCallbacks.push(arg);
49828
49839
  };
49829
49840
  var cancellationToken;
49830
- var requestedExternalEmitHelperNames = /* @__PURE__ */ new Set();
49831
- var requestedExternalEmitHelpers;
49832
- var externalHelpersModule;
49833
49841
  var scanner2;
49834
49842
  var Symbol47 = objectAllocator.getSymbolConstructor();
49835
49843
  var Type29 = objectAllocator.getTypeConstructor();
@@ -70542,12 +70550,17 @@ function createTypeChecker(host) {
70542
70550
  }
70543
70551
  }
70544
70552
  function applyToReturnTypes(source, target, callback) {
70545
- const sourceTypePredicate = getTypePredicateOfSignature(source);
70546
70553
  const targetTypePredicate = getTypePredicateOfSignature(target);
70547
- if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
70548
- callback(sourceTypePredicate.type, targetTypePredicate.type);
70549
- } else {
70550
- callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
70554
+ if (targetTypePredicate) {
70555
+ const sourceTypePredicate = getTypePredicateOfSignature(source);
70556
+ if (sourceTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
70557
+ callback(sourceTypePredicate.type, targetTypePredicate.type);
70558
+ return;
70559
+ }
70560
+ }
70561
+ const targetReturnType = getReturnTypeOfSignature(target);
70562
+ if (couldContainTypeVariables(targetReturnType)) {
70563
+ callback(getReturnTypeOfSignature(source), targetReturnType);
70551
70564
  }
70552
70565
  }
70553
70566
  function createInferenceContext(typeParameters, signature, flags, compareTypes) {
@@ -75053,7 +75066,31 @@ function createTypeChecker(host) {
75053
75066
  if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* Union */) {
75054
75067
  contextualReturnType = filterType(contextualReturnType, (type) => !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator));
75055
75068
  }
75056
- return node.asteriskToken ? contextualReturnType : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator);
75069
+ if (node.asteriskToken) {
75070
+ const iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(contextualReturnType, isAsyncGenerator);
75071
+ const yieldType = (iterationTypes == null ? void 0 : iterationTypes.yieldType) ?? silentNeverType;
75072
+ const returnType = getContextualType2(node, contextFlags) ?? silentNeverType;
75073
+ const nextType = (iterationTypes == null ? void 0 : iterationTypes.nextType) ?? unknownType;
75074
+ const generatorType = createGeneratorType(
75075
+ yieldType,
75076
+ returnType,
75077
+ nextType,
75078
+ /*isAsyncGenerator*/
75079
+ false
75080
+ );
75081
+ if (isAsyncGenerator) {
75082
+ const asyncGeneratorType = createGeneratorType(
75083
+ yieldType,
75084
+ returnType,
75085
+ nextType,
75086
+ /*isAsyncGenerator*/
75087
+ true
75088
+ );
75089
+ return getUnionType([generatorType, asyncGeneratorType]);
75090
+ }
75091
+ return generatorType;
75092
+ }
75093
+ return getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator);
75057
75094
  }
75058
75095
  }
75059
75096
  return void 0;
@@ -80823,7 +80860,7 @@ function createTypeChecker(host) {
80823
80860
  if (nextType) nextType = getWidenedType(nextType);
80824
80861
  }
80825
80862
  if (isGenerator) {
80826
- return createGeneratorReturnType(
80863
+ return createGeneratorType(
80827
80864
  yieldType || neverType,
80828
80865
  returnType || fallbackReturnType,
80829
80866
  nextType || getContextualIterationType(2 /* Next */, func) || unknownType,
@@ -80833,7 +80870,7 @@ function createTypeChecker(host) {
80833
80870
  return isAsync ? createPromiseType(returnType || fallbackReturnType) : returnType || fallbackReturnType;
80834
80871
  }
80835
80872
  }
80836
- function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
80873
+ function createGeneratorType(yieldType, returnType, nextType, isAsyncGenerator) {
80837
80874
  const resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
80838
80875
  const globalGeneratorType = resolver.getGlobalGeneratorType(
80839
80876
  /*reportErrors*/
@@ -83218,7 +83255,7 @@ function createTypeChecker(host) {
83218
83255
  const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags & 2 /* Async */) !== 0) || anyType;
83219
83256
  const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags & 2 /* Async */) !== 0) || generatorYieldType;
83220
83257
  const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags & 2 /* Async */) !== 0) || unknownType;
83221
- const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */));
83258
+ const generatorInstantiation = createGeneratorType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */));
83222
83259
  return checkTypeAssignableTo(generatorInstantiation, returnType, errorNode);
83223
83260
  }
83224
83261
  function checkClassForDuplicateDeclarations(node) {
@@ -90208,38 +90245,40 @@ function createTypeChecker(host) {
90208
90245
  amalgamatedDuplicates = void 0;
90209
90246
  }
90210
90247
  function checkExternalEmitHelpers(location, helpers) {
90211
- if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
90248
+ if (compilerOptions.importHelpers) {
90212
90249
  const sourceFile = getSourceFileOfNode(location);
90213
90250
  if (isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 33554432 /* Ambient */)) {
90214
90251
  const helpersModule = resolveHelpersModule(sourceFile, location);
90215
90252
  if (helpersModule !== unknownSymbol) {
90216
- const uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
90217
- for (let helper = 1 /* FirstEmitHelper */; helper <= 16777216 /* LastEmitHelper */; helper <<= 1) {
90218
- if (uncheckedHelpers & helper) {
90219
- for (const name of getHelperNames(helper)) {
90220
- if (requestedExternalEmitHelperNames.has(name)) continue;
90221
- requestedExternalEmitHelperNames.add(name);
90222
- const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
90223
- if (!symbol) {
90224
- error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
90225
- } else if (helper & 524288 /* ClassPrivateFieldGet */) {
90226
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
90227
- error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 4);
90228
- }
90229
- } else if (helper & 1048576 /* ClassPrivateFieldSet */) {
90230
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
90231
- error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 5);
90232
- }
90233
- } else if (helper & 1024 /* SpreadArray */) {
90234
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
90235
- error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 3);
90253
+ const links = getSymbolLinks(helpersModule);
90254
+ links.requestedExternalEmitHelpers ?? (links.requestedExternalEmitHelpers = 0);
90255
+ if ((links.requestedExternalEmitHelpers & helpers) !== helpers) {
90256
+ const uncheckedHelpers = helpers & ~links.requestedExternalEmitHelpers;
90257
+ for (let helper = 1 /* FirstEmitHelper */; helper <= 16777216 /* LastEmitHelper */; helper <<= 1) {
90258
+ if (uncheckedHelpers & helper) {
90259
+ for (const name of getHelperNames(helper)) {
90260
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
90261
+ if (!symbol) {
90262
+ error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
90263
+ } else if (helper & 524288 /* ClassPrivateFieldGet */) {
90264
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
90265
+ error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 4);
90266
+ }
90267
+ } else if (helper & 1048576 /* ClassPrivateFieldSet */) {
90268
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
90269
+ error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 5);
90270
+ }
90271
+ } else if (helper & 1024 /* SpreadArray */) {
90272
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
90273
+ error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 3);
90274
+ }
90236
90275
  }
90237
90276
  }
90238
90277
  }
90239
90278
  }
90240
90279
  }
90280
+ links.requestedExternalEmitHelpers |= helpers;
90241
90281
  }
90242
- requestedExternalEmitHelpers |= helpers;
90243
90282
  }
90244
90283
  }
90245
90284
  }
@@ -90300,10 +90339,11 @@ function createTypeChecker(host) {
90300
90339
  }
90301
90340
  }
90302
90341
  function resolveHelpersModule(file, errorNode) {
90303
- if (!externalHelpersModule) {
90304
- externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
90342
+ const links = getNodeLinks(file);
90343
+ if (!links.externalHelpersModule) {
90344
+ links.externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
90305
90345
  }
90306
- return externalHelpersModule;
90346
+ return links.externalHelpersModule;
90307
90347
  }
90308
90348
  function checkGrammarModifiers(node) {
90309
90349
  var _a;
@@ -93865,8 +93905,8 @@ function collectExternalModuleInfo(context, sourceFile) {
93865
93905
  const exportSpecifiers = new IdentifierNameMultiMap();
93866
93906
  const exportedBindings = [];
93867
93907
  const uniqueExports = /* @__PURE__ */ new Map();
93908
+ const exportedFunctions = /* @__PURE__ */ new Set();
93868
93909
  let exportedNames;
93869
- let exportedFunctions;
93870
93910
  let hasExportDefault = false;
93871
93911
  let exportEquals;
93872
93912
  let hasExportStarsToExportValues = false;
@@ -93926,19 +93966,12 @@ function collectExternalModuleInfo(context, sourceFile) {
93926
93966
  break;
93927
93967
  case 262 /* FunctionDeclaration */:
93928
93968
  if (hasSyntacticModifier(node, 32 /* Export */)) {
93929
- exportedFunctions = append(exportedFunctions, node);
93930
- if (hasSyntacticModifier(node, 2048 /* Default */)) {
93931
- if (!hasExportDefault) {
93932
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
93933
- hasExportDefault = true;
93934
- }
93935
- } else {
93936
- const name = node.name;
93937
- if (!uniqueExports.get(idText(name))) {
93938
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
93939
- uniqueExports.set(idText(name), true);
93940
- }
93941
- }
93969
+ addExportedFunctionDeclaration(
93970
+ node,
93971
+ /*name*/
93972
+ void 0,
93973
+ hasSyntacticModifier(node, 2048 /* Default */)
93974
+ );
93942
93975
  }
93943
93976
  break;
93944
93977
  case 263 /* ClassDeclaration */:
@@ -93974,6 +94007,10 @@ function collectExternalModuleInfo(context, sourceFile) {
93974
94007
  }
93975
94008
  const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
93976
94009
  if (decl) {
94010
+ if (decl.kind === 262 /* FunctionDeclaration */) {
94011
+ addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
94012
+ continue;
94013
+ }
93977
94014
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
93978
94015
  }
93979
94016
  uniqueExports.set(idText(specifier.name), true);
@@ -93981,6 +94018,21 @@ function collectExternalModuleInfo(context, sourceFile) {
93981
94018
  }
93982
94019
  }
93983
94020
  }
94021
+ function addExportedFunctionDeclaration(node, name, isDefault) {
94022
+ exportedFunctions.add(node);
94023
+ if (isDefault) {
94024
+ if (!hasExportDefault) {
94025
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name ?? context.factory.getDeclarationName(node));
94026
+ hasExportDefault = true;
94027
+ }
94028
+ } else {
94029
+ name ?? (name = node.name);
94030
+ if (!uniqueExports.get(idText(name))) {
94031
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
94032
+ uniqueExports.set(idText(name), true);
94033
+ }
94034
+ }
94035
+ }
93984
94036
  }
93985
94037
  function collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings) {
93986
94038
  if (isBindingPattern(decl.name)) {
@@ -111273,10 +111325,8 @@ function transformModule(context) {
111273
111325
  );
111274
111326
  }
111275
111327
  }
111276
- if (some(currentModuleInfo.exportedFunctions)) {
111277
- for (const f of currentModuleInfo.exportedFunctions) {
111278
- appendExportsOfHoistedDeclaration(statements, f);
111279
- }
111328
+ for (const f of currentModuleInfo.exportedFunctions) {
111329
+ appendExportsOfHoistedDeclaration(statements, f);
111280
111330
  }
111281
111331
  append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, isStatement));
111282
111332
  addRange(statements, visitNodes2(node.statements, topLevelVisitor, isStatement, statementOffset));
@@ -111593,10 +111643,8 @@ function transformModule(context) {
111593
111643
  if (some(currentModuleInfo.exportedNames)) {
111594
111644
  append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
111595
111645
  }
111596
- if (some(currentModuleInfo.exportedFunctions)) {
111597
- for (const f of currentModuleInfo.exportedFunctions) {
111598
- appendExportsOfHoistedDeclaration(statements, f);
111599
- }
111646
+ for (const f of currentModuleInfo.exportedFunctions) {
111647
+ appendExportsOfHoistedDeclaration(statements, f);
111600
111648
  }
111601
111649
  append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, isStatement));
111602
111650
  if (moduleKind === 2 /* AMD */) {
@@ -113310,7 +113358,7 @@ function transformSystemModule(context) {
113310
113358
  if (!moduleInfo.hasExportStarsToExportValues) {
113311
113359
  return;
113312
113360
  }
113313
- if (!some(moduleInfo.exportedNames) && !some(moduleInfo.exportedFunctions) && moduleInfo.exportSpecifiers.size === 0) {
113361
+ if (!some(moduleInfo.exportedNames) && moduleInfo.exportedFunctions.size === 0 && moduleInfo.exportSpecifiers.size === 0) {
113314
113362
  let hasExportDeclarationWithExportClause = false;
113315
113363
  for (const externalImport of moduleInfo.externalImports) {
113316
113364
  if (externalImport.kind === 278 /* ExportDeclaration */ && externalImport.exportClause) {
@@ -113341,19 +113389,17 @@ function transformSystemModule(context) {
113341
113389
  );
113342
113390
  }
113343
113391
  }
113344
- if (moduleInfo.exportedFunctions) {
113345
- for (const f of moduleInfo.exportedFunctions) {
113346
- if (hasSyntacticModifier(f, 2048 /* Default */)) {
113347
- continue;
113348
- }
113349
- Debug.assert(!!f.name);
113350
- exportedNames.push(
113351
- factory2.createPropertyAssignment(
113352
- factory2.createStringLiteralFromNode(f.name),
113353
- factory2.createTrue()
113354
- )
113355
- );
113392
+ for (const f of moduleInfo.exportedFunctions) {
113393
+ if (hasSyntacticModifier(f, 2048 /* Default */)) {
113394
+ continue;
113356
113395
  }
113396
+ Debug.assert(!!f.name);
113397
+ exportedNames.push(
113398
+ factory2.createPropertyAssignment(
113399
+ factory2.createStringLiteralFromNode(f.name),
113400
+ factory2.createTrue()
113401
+ )
113402
+ );
113357
113403
  }
113358
113404
  const exportedNamesStorageRef = factory2.createUniqueName("exportedNames");
113359
113405
  statements.push(
@@ -177769,7 +177815,14 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
177769
177815
  if (copiedFrom == null ? void 0 : copiedFrom.range) {
177770
177816
  Debug.assert(copiedFrom.range.length === pastedText.length);
177771
177817
  copiedFrom.range.forEach((copy) => {
177772
- addRange(statements, copiedFrom.file.statements, getLineOfLocalPosition(copiedFrom.file, copy.pos), getLineOfLocalPosition(copiedFrom.file, copy.end) + 1);
177818
+ const statementsInSourceFile = copiedFrom.file.statements;
177819
+ const startNodeIndex = findIndex(statementsInSourceFile, (s) => s.end > copy.pos);
177820
+ if (startNodeIndex === -1) return void 0;
177821
+ let endNodeIndex = findIndex(statementsInSourceFile, (s) => s.end >= copy.end, startNodeIndex);
177822
+ if (endNodeIndex !== -1 && copy.end <= statementsInSourceFile[endNodeIndex].getStart()) {
177823
+ endNodeIndex--;
177824
+ }
177825
+ statements.push(...statementsInSourceFile.slice(startNodeIndex, endNodeIndex === -1 ? statementsInSourceFile.length : endNodeIndex + 1));
177773
177826
  });
177774
177827
  const usage = getUsageInfo(copiedFrom.file, statements, originalProgram.getTypeChecker(), getExistingLocals(updatedFile, statements, originalProgram.getTypeChecker()));
177775
177828
  Debug.assertIsDefined(originalProgram);