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/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240528`;
21
+ var version = `${versionMajorMinor}.0-dev.20240530`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6091,8 +6091,10 @@ var Diagnostics = {
6091
6091
  _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."),
6092
6092
  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."),
6093
6093
  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."),
6094
- 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."),
6094
+ 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."),
6095
6095
  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."),
6096
+ 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."),
6097
+ 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."),
6096
6098
  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."),
6097
6099
  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."),
6098
6100
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -8812,12 +8814,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8812
8814
  }
8813
8815
  if (ch === 92 /* backslash */ && !jsxAttributeString) {
8814
8816
  result += text.substring(start2, pos);
8815
- result += scanEscapeSequence(
8816
- /*shouldEmitInvalidEscapeError*/
8817
- true,
8818
- /*isRegularExpression*/
8819
- false
8820
- );
8817
+ result += scanEscapeSequence(1 /* String */ | 2 /* ReportErrors */);
8821
8818
  start2 = pos;
8822
8819
  continue;
8823
8820
  }
@@ -8860,11 +8857,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8860
8857
  }
8861
8858
  if (currChar === 92 /* backslash */) {
8862
8859
  contents += text.substring(start2, pos);
8863
- contents += scanEscapeSequence(
8864
- shouldEmitInvalidEscapeError,
8865
- /*isRegularExpression*/
8866
- false
8867
- );
8860
+ contents += scanEscapeSequence(1 /* String */ | (shouldEmitInvalidEscapeError ? 2 /* ReportErrors */ : 0));
8868
8861
  start2 = pos;
8869
8862
  continue;
8870
8863
  }
@@ -8884,7 +8877,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8884
8877
  tokenValue = contents;
8885
8878
  return resultingToken;
8886
8879
  }
8887
- function scanEscapeSequence(shouldEmitInvalidEscapeError, isRegularExpression) {
8880
+ function scanEscapeSequence(flags) {
8888
8881
  const start2 = pos;
8889
8882
  pos++;
8890
8883
  if (pos >= end) {
@@ -8912,9 +8905,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8912
8905
  pos++;
8913
8906
  }
8914
8907
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
8915
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
8908
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
8916
8909
  const code = parseInt(text.substring(start2 + 1, pos), 8);
8917
- if (isRegularExpression !== "annex-b") {
8910
+ if (flags & 4 /* RegularExpression */ && !(flags & 32 /* AtomEscape */) && ch !== 48 /* _0 */) {
8911
+ error(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"));
8912
+ } else {
8918
8913
  error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
8919
8914
  }
8920
8915
  return String.fromCharCode(code);
@@ -8923,8 +8918,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8923
8918
  case 56 /* _8 */:
8924
8919
  case 57 /* _9 */:
8925
8920
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
8926
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
8927
- error(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
8921
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
8922
+ if (flags & 4 /* RegularExpression */ && !(flags & 32 /* AtomEscape */)) {
8923
+ error(Diagnostics.Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class, start2, pos - start2);
8924
+ } else {
8925
+ error(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
8926
+ }
8928
8927
  return String.fromCharCode(ch);
8929
8928
  }
8930
8929
  return text.substring(start2, pos);
@@ -8945,14 +8944,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8945
8944
  case 34 /* doubleQuote */:
8946
8945
  return '"';
8947
8946
  case 117 /* u */:
8948
- if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
8947
+ if (flags & 17 /* ScanExtendedUnicodeEscape */ && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
8949
8948
  pos -= 2;
8950
- return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
8949
+ return scanExtendedUnicodeEscape(!!(flags & 6 /* ReportInvalidEscapeErrors */));
8951
8950
  }
8952
8951
  for (; pos < start2 + 6; pos++) {
8953
8952
  if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
8954
8953
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
8955
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
8954
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
8956
8955
  error(Diagnostics.Hexadecimal_digit_expected);
8957
8956
  }
8958
8957
  return text.substring(start2, pos);
@@ -8961,7 +8960,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8961
8960
  tokenFlags |= 1024 /* UnicodeEscape */;
8962
8961
  const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
8963
8962
  const escapedValueString = String.fromCharCode(escapedValue);
8964
- if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
8963
+ if (flags & 16 /* AnyUnicodeMode */ && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
8965
8964
  const nextStart = pos;
8966
8965
  let nextPos = pos + 2;
8967
8966
  for (; nextPos < nextStart + 6; nextPos++) {
@@ -8980,7 +8979,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8980
8979
  for (; pos < start2 + 4; pos++) {
8981
8980
  if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
8982
8981
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
8983
- if (isRegularExpression || shouldEmitInvalidEscapeError) {
8982
+ if (flags & 6 /* ReportInvalidEscapeErrors */) {
8984
8983
  error(Diagnostics.Hexadecimal_digit_expected);
8985
8984
  }
8986
8985
  return text.substring(start2, pos);
@@ -8997,7 +8996,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8997
8996
  case 8233 /* paragraphSeparator */:
8998
8997
  return "";
8999
8998
  default:
9000
- if (isRegularExpression === true && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
8999
+ if (flags & 16 /* AnyUnicodeMode */ || flags & 4 /* RegularExpression */ && !(flags & 8 /* AnnexB */) && isIdentifierPart(ch, languageVersion)) {
9001
9000
  error(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2);
9002
9001
  }
9003
9002
  return String.fromCharCode(ch);
@@ -9696,6 +9695,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9696
9695
  const startOfRegExpBody = tokenStart + 1;
9697
9696
  pos = startOfRegExpBody;
9698
9697
  let inEscape = false;
9698
+ let namedCaptureGroups = false;
9699
9699
  let inCharacterClass = false;
9700
9700
  while (true) {
9701
9701
  const ch = charCodeChecked(pos);
@@ -9713,6 +9713,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9713
9713
  inEscape = true;
9714
9714
  } else if (ch === 93 /* closeBracket */) {
9715
9715
  inCharacterClass = false;
9716
+ } 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 */) {
9717
+ namedCaptureGroups = true;
9716
9718
  }
9717
9719
  pos++;
9718
9720
  }
@@ -9780,7 +9782,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9780
9782
  scanRegularExpressionWorker(
9781
9783
  regExpFlags,
9782
9784
  /*annexB*/
9783
- true
9785
+ true,
9786
+ namedCaptureGroups
9784
9787
  );
9785
9788
  });
9786
9789
  }
@@ -9790,12 +9793,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9790
9793
  }
9791
9794
  return token;
9792
9795
  }
9793
- function scanRegularExpressionWorker(regExpFlags, annexB) {
9796
+ function scanRegularExpressionWorker(regExpFlags, annexB, namedCaptureGroups) {
9794
9797
  var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
9795
9798
  var anyUnicodeMode = !!(regExpFlags & 96 /* AnyUnicodeMode */);
9796
- if (anyUnicodeMode) {
9797
- annexB = false;
9798
- }
9799
+ var anyUnicodeModeOrNonAnnexB = anyUnicodeMode || !annexB;
9799
9800
  var mayContainStrings = false;
9800
9801
  var numberOfCapturingGroups = 0;
9801
9802
  var groupSpecifiers;
@@ -9850,7 +9851,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9850
9851
  case 61 /* equals */:
9851
9852
  case 33 /* exclamation */:
9852
9853
  pos++;
9853
- isPreviousTermQuantifiable = annexB;
9854
+ isPreviousTermQuantifiable = !anyUnicodeModeOrNonAnnexB;
9854
9855
  break;
9855
9856
  case 60 /* lessThan */:
9856
9857
  const groupNameStart = pos;
@@ -9904,6 +9905,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9904
9905
  const digitsStart = pos;
9905
9906
  scanDigits();
9906
9907
  const min2 = tokenValue;
9908
+ if (!anyUnicodeModeOrNonAnnexB && !min2) {
9909
+ isPreviousTermQuantifiable = true;
9910
+ break;
9911
+ }
9907
9912
  if (charCodeChecked(pos) === 44 /* comma */) {
9908
9913
  pos++;
9909
9914
  scanDigits();
@@ -9912,25 +9917,29 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9912
9917
  if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
9913
9918
  error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
9914
9919
  } else {
9915
- if (anyUnicodeMode) {
9916
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
9917
- }
9920
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
9918
9921
  isPreviousTermQuantifiable = true;
9919
9922
  break;
9920
9923
  }
9921
- }
9922
- if (max && Number.parseInt(min2) > Number.parseInt(max)) {
9924
+ } else if (max && Number.parseInt(min2) > Number.parseInt(max) && (anyUnicodeModeOrNonAnnexB || charCodeChecked(pos) === 125 /* closeBrace */)) {
9923
9925
  error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
9924
9926
  }
9925
9927
  } else if (!min2) {
9926
- if (anyUnicodeMode) {
9928
+ if (anyUnicodeModeOrNonAnnexB) {
9927
9929
  error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
9928
9930
  }
9929
9931
  isPreviousTermQuantifiable = true;
9930
9932
  break;
9931
9933
  }
9932
- scanExpectedChar(125 /* closeBrace */);
9933
- pos--;
9934
+ if (charCodeChecked(pos) !== 125 /* closeBrace */) {
9935
+ if (anyUnicodeModeOrNonAnnexB) {
9936
+ error(Diagnostics._0_expected, pos, 0, String.fromCharCode(125 /* closeBrace */));
9937
+ pos--;
9938
+ } else {
9939
+ isPreviousTermQuantifiable = true;
9940
+ break;
9941
+ }
9942
+ }
9934
9943
  case 42 /* asterisk */:
9935
9944
  case 43 /* plus */:
9936
9945
  case 63 /* question */:
@@ -9963,7 +9972,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9963
9972
  }
9964
9973
  case 93 /* closeBracket */:
9965
9974
  case 125 /* closeBrace */:
9966
- if (anyUnicodeMode || ch === 41 /* closeParen */) {
9975
+ if (anyUnicodeModeOrNonAnnexB || ch === 41 /* closeParen */) {
9967
9976
  error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
9968
9977
  }
9969
9978
  pos++;
@@ -10012,7 +10021,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10012
10021
  true
10013
10022
  );
10014
10023
  scanExpectedChar(62 /* greaterThan */);
10015
- } else if (anyUnicodeMode) {
10024
+ } else if (anyUnicodeModeOrNonAnnexB || namedCaptureGroups) {
10016
10025
  error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
10017
10026
  }
10018
10027
  break;
@@ -10055,9 +10064,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10055
10064
  pos++;
10056
10065
  return String.fromCharCode(ch & 31);
10057
10066
  }
10058
- if (anyUnicodeMode) {
10067
+ if (anyUnicodeModeOrNonAnnexB) {
10059
10068
  error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
10060
- } else if (atomEscape && annexB) {
10069
+ } else if (atomEscape) {
10061
10070
  pos--;
10062
10071
  return "\\";
10063
10072
  }
@@ -10082,10 +10091,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10082
10091
  default:
10083
10092
  pos--;
10084
10093
  return scanEscapeSequence(
10085
- /*shouldEmitInvalidEscapeError*/
10086
- anyUnicodeMode,
10087
- /*isRegularExpression*/
10088
- annexB ? "annex-b" : true
10094
+ 4 /* RegularExpression */ | (annexB ? 8 /* AnnexB */ : 0) | (anyUnicodeMode ? 16 /* AnyUnicodeMode */ : 0) | (atomEscape ? 32 /* AtomEscape */ : 0)
10089
10095
  );
10090
10096
  }
10091
10097
  }
@@ -10127,12 +10133,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10127
10133
  if (isClassContentExit(ch2)) {
10128
10134
  return;
10129
10135
  }
10130
- if (!minCharacter && !annexB) {
10136
+ if (!minCharacter && anyUnicodeModeOrNonAnnexB) {
10131
10137
  error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
10132
10138
  }
10133
10139
  const maxStart = pos;
10134
10140
  const maxCharacter = scanClassAtom();
10135
- if (!maxCharacter && !annexB) {
10141
+ if (!maxCharacter && anyUnicodeModeOrNonAnnexB) {
10136
10142
  error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
10137
10143
  continue;
10138
10144
  }
@@ -10562,8 +10568,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10562
10568
  if (!anyUnicodeMode) {
10563
10569
  error(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
10564
10570
  }
10565
- } else if (anyUnicodeMode) {
10571
+ } else if (anyUnicodeModeOrNonAnnexB) {
10566
10572
  error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
10573
+ } else {
10574
+ pos--;
10575
+ return false;
10567
10576
  }
10568
10577
  return true;
10569
10578
  }
@@ -10603,11 +10612,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10603
10612
  }
10604
10613
  });
10605
10614
  forEach(decimalEscapes, (escape) => {
10606
- if (!annexB && escape.value > numberOfCapturingGroups) {
10615
+ if (escape.value > numberOfCapturingGroups) {
10607
10616
  if (numberOfCapturingGroups) {
10608
10617
  error(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);
10609
10618
  } else {
10610
- error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
10619
+ error(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);
10611
10620
  }
10612
10621
  }
10613
10622
  });
@@ -25486,7 +25495,7 @@ var addDisposableResourceHelper = {
25486
25495
  var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
25487
25496
  if (value !== null && value !== void 0) {
25488
25497
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
25489
- var dispose;
25498
+ var dispose, inner;
25490
25499
  if (async) {
25491
25500
  if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
25492
25501
  dispose = value[Symbol.asyncDispose];
@@ -25494,8 +25503,10 @@ var addDisposableResourceHelper = {
25494
25503
  if (dispose === void 0) {
25495
25504
  if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
25496
25505
  dispose = value[Symbol.dispose];
25506
+ if (async) inner = dispose;
25497
25507
  }
25498
25508
  if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
25509
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
25499
25510
  env.stack.push({ value: value, dispose: dispose, async: async });
25500
25511
  }
25501
25512
  else if (async) {
@@ -45032,9 +45043,6 @@ function createTypeChecker(host) {
45032
45043
  deferredDiagnosticsCallbacks.push(arg);
45033
45044
  };
45034
45045
  var cancellationToken;
45035
- var requestedExternalEmitHelperNames = /* @__PURE__ */ new Set();
45036
- var requestedExternalEmitHelpers;
45037
- var externalHelpersModule;
45038
45046
  var scanner;
45039
45047
  var Symbol12 = objectAllocator.getSymbolConstructor();
45040
45048
  var Type7 = objectAllocator.getTypeConstructor();
@@ -65747,12 +65755,17 @@ function createTypeChecker(host) {
65747
65755
  }
65748
65756
  }
65749
65757
  function applyToReturnTypes(source, target, callback) {
65750
- const sourceTypePredicate = getTypePredicateOfSignature(source);
65751
65758
  const targetTypePredicate = getTypePredicateOfSignature(target);
65752
- if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
65753
- callback(sourceTypePredicate.type, targetTypePredicate.type);
65754
- } else {
65755
- callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
65759
+ if (targetTypePredicate) {
65760
+ const sourceTypePredicate = getTypePredicateOfSignature(source);
65761
+ if (sourceTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
65762
+ callback(sourceTypePredicate.type, targetTypePredicate.type);
65763
+ return;
65764
+ }
65765
+ }
65766
+ const targetReturnType = getReturnTypeOfSignature(target);
65767
+ if (couldContainTypeVariables(targetReturnType)) {
65768
+ callback(getReturnTypeOfSignature(source), targetReturnType);
65756
65769
  }
65757
65770
  }
65758
65771
  function createInferenceContext(typeParameters, signature, flags, compareTypes) {
@@ -70258,7 +70271,31 @@ function createTypeChecker(host) {
70258
70271
  if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* Union */) {
70259
70272
  contextualReturnType = filterType(contextualReturnType, (type) => !!getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsyncGenerator));
70260
70273
  }
70261
- return node.asteriskToken ? contextualReturnType : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator);
70274
+ if (node.asteriskToken) {
70275
+ const iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(contextualReturnType, isAsyncGenerator);
70276
+ const yieldType = (iterationTypes == null ? void 0 : iterationTypes.yieldType) ?? silentNeverType;
70277
+ const returnType = getContextualType(node, contextFlags) ?? silentNeverType;
70278
+ const nextType = (iterationTypes == null ? void 0 : iterationTypes.nextType) ?? unknownType;
70279
+ const generatorType = createGeneratorType(
70280
+ yieldType,
70281
+ returnType,
70282
+ nextType,
70283
+ /*isAsyncGenerator*/
70284
+ false
70285
+ );
70286
+ if (isAsyncGenerator) {
70287
+ const asyncGeneratorType = createGeneratorType(
70288
+ yieldType,
70289
+ returnType,
70290
+ nextType,
70291
+ /*isAsyncGenerator*/
70292
+ true
70293
+ );
70294
+ return getUnionType([generatorType, asyncGeneratorType]);
70295
+ }
70296
+ return generatorType;
70297
+ }
70298
+ return getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, isAsyncGenerator);
70262
70299
  }
70263
70300
  }
70264
70301
  return void 0;
@@ -76028,7 +76065,7 @@ function createTypeChecker(host) {
76028
76065
  if (nextType) nextType = getWidenedType(nextType);
76029
76066
  }
76030
76067
  if (isGenerator) {
76031
- return createGeneratorReturnType(
76068
+ return createGeneratorType(
76032
76069
  yieldType || neverType,
76033
76070
  returnType || fallbackReturnType,
76034
76071
  nextType || getContextualIterationType(2 /* Next */, func) || unknownType,
@@ -76038,7 +76075,7 @@ function createTypeChecker(host) {
76038
76075
  return isAsync ? createPromiseType(returnType || fallbackReturnType) : returnType || fallbackReturnType;
76039
76076
  }
76040
76077
  }
76041
- function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
76078
+ function createGeneratorType(yieldType, returnType, nextType, isAsyncGenerator) {
76042
76079
  const resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
76043
76080
  const globalGeneratorType = resolver.getGlobalGeneratorType(
76044
76081
  /*reportErrors*/
@@ -78423,7 +78460,7 @@ function createTypeChecker(host) {
78423
78460
  const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags & 2 /* Async */) !== 0) || anyType;
78424
78461
  const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags & 2 /* Async */) !== 0) || generatorYieldType;
78425
78462
  const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags & 2 /* Async */) !== 0) || unknownType;
78426
- const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */));
78463
+ const generatorInstantiation = createGeneratorType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & 2 /* Async */));
78427
78464
  return checkTypeAssignableTo(generatorInstantiation, returnType, errorNode);
78428
78465
  }
78429
78466
  function checkClassForDuplicateDeclarations(node) {
@@ -85413,38 +85450,40 @@ function createTypeChecker(host) {
85413
85450
  amalgamatedDuplicates = void 0;
85414
85451
  }
85415
85452
  function checkExternalEmitHelpers(location, helpers) {
85416
- if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
85453
+ if (compilerOptions.importHelpers) {
85417
85454
  const sourceFile = getSourceFileOfNode(location);
85418
85455
  if (isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 33554432 /* Ambient */)) {
85419
85456
  const helpersModule = resolveHelpersModule(sourceFile, location);
85420
85457
  if (helpersModule !== unknownSymbol) {
85421
- const uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
85422
- for (let helper = 1 /* FirstEmitHelper */; helper <= 16777216 /* LastEmitHelper */; helper <<= 1) {
85423
- if (uncheckedHelpers & helper) {
85424
- for (const name of getHelperNames(helper)) {
85425
- if (requestedExternalEmitHelperNames.has(name)) continue;
85426
- requestedExternalEmitHelperNames.add(name);
85427
- const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
85428
- if (!symbol) {
85429
- error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
85430
- } else if (helper & 524288 /* ClassPrivateFieldGet */) {
85431
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
85432
- error(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);
85433
- }
85434
- } else if (helper & 1048576 /* ClassPrivateFieldSet */) {
85435
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
85436
- error(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);
85437
- }
85438
- } else if (helper & 1024 /* SpreadArray */) {
85439
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
85440
- error(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);
85458
+ const links = getSymbolLinks(helpersModule);
85459
+ links.requestedExternalEmitHelpers ?? (links.requestedExternalEmitHelpers = 0);
85460
+ if ((links.requestedExternalEmitHelpers & helpers) !== helpers) {
85461
+ const uncheckedHelpers = helpers & ~links.requestedExternalEmitHelpers;
85462
+ for (let helper = 1 /* FirstEmitHelper */; helper <= 16777216 /* LastEmitHelper */; helper <<= 1) {
85463
+ if (uncheckedHelpers & helper) {
85464
+ for (const name of getHelperNames(helper)) {
85465
+ const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
85466
+ if (!symbol) {
85467
+ error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
85468
+ } else if (helper & 524288 /* ClassPrivateFieldGet */) {
85469
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
85470
+ error(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);
85471
+ }
85472
+ } else if (helper & 1048576 /* ClassPrivateFieldSet */) {
85473
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
85474
+ error(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);
85475
+ }
85476
+ } else if (helper & 1024 /* SpreadArray */) {
85477
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
85478
+ error(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);
85479
+ }
85441
85480
  }
85442
85481
  }
85443
85482
  }
85444
85483
  }
85445
85484
  }
85485
+ links.requestedExternalEmitHelpers |= helpers;
85446
85486
  }
85447
- requestedExternalEmitHelpers |= helpers;
85448
85487
  }
85449
85488
  }
85450
85489
  }
@@ -85505,10 +85544,11 @@ function createTypeChecker(host) {
85505
85544
  }
85506
85545
  }
85507
85546
  function resolveHelpersModule(file, errorNode) {
85508
- if (!externalHelpersModule) {
85509
- externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
85547
+ const links = getNodeLinks(file);
85548
+ if (!links.externalHelpersModule) {
85549
+ links.externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
85510
85550
  }
85511
- return externalHelpersModule;
85551
+ return links.externalHelpersModule;
85512
85552
  }
85513
85553
  function checkGrammarModifiers(node) {
85514
85554
  var _a;
@@ -88898,8 +88938,8 @@ function collectExternalModuleInfo(context, sourceFile) {
88898
88938
  const exportSpecifiers = new IdentifierNameMultiMap();
88899
88939
  const exportedBindings = [];
88900
88940
  const uniqueExports = /* @__PURE__ */ new Map();
88941
+ const exportedFunctions = /* @__PURE__ */ new Set();
88901
88942
  let exportedNames;
88902
- let exportedFunctions;
88903
88943
  let hasExportDefault = false;
88904
88944
  let exportEquals;
88905
88945
  let hasExportStarsToExportValues = false;
@@ -88959,19 +88999,12 @@ function collectExternalModuleInfo(context, sourceFile) {
88959
88999
  break;
88960
89000
  case 262 /* FunctionDeclaration */:
88961
89001
  if (hasSyntacticModifier(node, 32 /* Export */)) {
88962
- exportedFunctions = append(exportedFunctions, node);
88963
- if (hasSyntacticModifier(node, 2048 /* Default */)) {
88964
- if (!hasExportDefault) {
88965
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
88966
- hasExportDefault = true;
88967
- }
88968
- } else {
88969
- const name = node.name;
88970
- if (!uniqueExports.get(idText(name))) {
88971
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
88972
- uniqueExports.set(idText(name), true);
88973
- }
88974
- }
89002
+ addExportedFunctionDeclaration(
89003
+ node,
89004
+ /*name*/
89005
+ void 0,
89006
+ hasSyntacticModifier(node, 2048 /* Default */)
89007
+ );
88975
89008
  }
88976
89009
  break;
88977
89010
  case 263 /* ClassDeclaration */:
@@ -89007,6 +89040,10 @@ function collectExternalModuleInfo(context, sourceFile) {
89007
89040
  }
89008
89041
  const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89009
89042
  if (decl) {
89043
+ if (decl.kind === 262 /* FunctionDeclaration */) {
89044
+ addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
89045
+ continue;
89046
+ }
89010
89047
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89011
89048
  }
89012
89049
  uniqueExports.set(idText(specifier.name), true);
@@ -89014,6 +89051,21 @@ function collectExternalModuleInfo(context, sourceFile) {
89014
89051
  }
89015
89052
  }
89016
89053
  }
89054
+ function addExportedFunctionDeclaration(node, name, isDefault) {
89055
+ exportedFunctions.add(node);
89056
+ if (isDefault) {
89057
+ if (!hasExportDefault) {
89058
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name ?? context.factory.getDeclarationName(node));
89059
+ hasExportDefault = true;
89060
+ }
89061
+ } else {
89062
+ name ?? (name = node.name);
89063
+ if (!uniqueExports.get(idText(name))) {
89064
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89065
+ uniqueExports.set(idText(name), true);
89066
+ }
89067
+ }
89068
+ }
89017
89069
  }
89018
89070
  function collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings) {
89019
89071
  if (isBindingPattern(decl.name)) {
@@ -106296,10 +106348,8 @@ function transformModule(context) {
106296
106348
  );
106297
106349
  }
106298
106350
  }
106299
- if (some(currentModuleInfo.exportedFunctions)) {
106300
- for (const f of currentModuleInfo.exportedFunctions) {
106301
- appendExportsOfHoistedDeclaration(statements, f);
106302
- }
106351
+ for (const f of currentModuleInfo.exportedFunctions) {
106352
+ appendExportsOfHoistedDeclaration(statements, f);
106303
106353
  }
106304
106354
  append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, isStatement));
106305
106355
  addRange(statements, visitNodes2(node.statements, topLevelVisitor, isStatement, statementOffset));
@@ -106616,10 +106666,8 @@ function transformModule(context) {
106616
106666
  if (some(currentModuleInfo.exportedNames)) {
106617
106667
  append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
106618
106668
  }
106619
- if (some(currentModuleInfo.exportedFunctions)) {
106620
- for (const f of currentModuleInfo.exportedFunctions) {
106621
- appendExportsOfHoistedDeclaration(statements, f);
106622
- }
106669
+ for (const f of currentModuleInfo.exportedFunctions) {
106670
+ appendExportsOfHoistedDeclaration(statements, f);
106623
106671
  }
106624
106672
  append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, isStatement));
106625
106673
  if (moduleKind === 2 /* AMD */) {
@@ -108333,7 +108381,7 @@ function transformSystemModule(context) {
108333
108381
  if (!moduleInfo.hasExportStarsToExportValues) {
108334
108382
  return;
108335
108383
  }
108336
- if (!some(moduleInfo.exportedNames) && !some(moduleInfo.exportedFunctions) && moduleInfo.exportSpecifiers.size === 0) {
108384
+ if (!some(moduleInfo.exportedNames) && moduleInfo.exportedFunctions.size === 0 && moduleInfo.exportSpecifiers.size === 0) {
108337
108385
  let hasExportDeclarationWithExportClause = false;
108338
108386
  for (const externalImport of moduleInfo.externalImports) {
108339
108387
  if (externalImport.kind === 278 /* ExportDeclaration */ && externalImport.exportClause) {
@@ -108364,19 +108412,17 @@ function transformSystemModule(context) {
108364
108412
  );
108365
108413
  }
108366
108414
  }
108367
- if (moduleInfo.exportedFunctions) {
108368
- for (const f of moduleInfo.exportedFunctions) {
108369
- if (hasSyntacticModifier(f, 2048 /* Default */)) {
108370
- continue;
108371
- }
108372
- Debug.assert(!!f.name);
108373
- exportedNames.push(
108374
- factory2.createPropertyAssignment(
108375
- factory2.createStringLiteralFromNode(f.name),
108376
- factory2.createTrue()
108377
- )
108378
- );
108415
+ for (const f of moduleInfo.exportedFunctions) {
108416
+ if (hasSyntacticModifier(f, 2048 /* Default */)) {
108417
+ continue;
108379
108418
  }
108419
+ Debug.assert(!!f.name);
108420
+ exportedNames.push(
108421
+ factory2.createPropertyAssignment(
108422
+ factory2.createStringLiteralFromNode(f.name),
108423
+ factory2.createTrue()
108424
+ )
108425
+ );
108380
108426
  }
108381
108427
  const exportedNamesStorageRef = factory2.createUniqueName("exportedNames");
108382
108428
  statements.push(