typescript 5.5.0-dev.20240428 → 5.5.0-dev.20240430

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 +931 -851
  2. package/lib/typescript.js +991 -895
  3. package/package.json +2 -2
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.20240428`;
21
+ var version = `${versionMajorMinor}.0-dev.20240430`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6203,7 +6203,7 @@ var Diagnostics = {
6203
6203
  Range_out_of_order_in_character_class: diag(1517, 1 /* Error */, "Range_out_of_order_in_character_class_1517", "Range out of order in character class."),
6204
6204
  Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class: diag(1518, 1 /* Error */, "Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_characte_1518", "Anything that would possibly match more than a single character is invalid inside a negated character class."),
6205
6205
  Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead: diag(1519, 1 /* Error */, "Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead_1519", "Operators must not be mixed within a character class. Wrap it in a nested class instead."),
6206
- Expected_a_class_set_oprand: diag(1520, 1 /* Error */, "Expected_a_class_set_oprand_1520", "Expected a class set oprand."),
6206
+ Expected_a_class_set_operand: diag(1520, 1 /* Error */, "Expected_a_class_set_operand_1520", "Expected a class set operand."),
6207
6207
  q_must_be_followed_by_string_alternatives_enclosed_in_braces: diag(1521, 1 /* Error */, "q_must_be_followed_by_string_alternatives_enclosed_in_braces_1521", "'\\q' must be followed by string alternatives enclosed in braces."),
6208
6208
  A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash: diag(1522, 1 /* Error */, "A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backs_1522", "A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?"),
6209
6209
  Expected_a_Unicode_property_name: diag(1523, 1 /* Error */, "Expected_a_Unicode_property_name_1523", "Expected a Unicode property name."),
@@ -8689,6 +8689,18 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8689
8689
  });
8690
8690
  }
8691
8691
  return scanner;
8692
+ function codePointUnchecked(pos2) {
8693
+ return codePointAt(text, pos2);
8694
+ }
8695
+ function codePointChecked(pos2) {
8696
+ return pos2 >= 0 && pos2 < end ? codePointUnchecked(pos2) : -1 /* EOF */;
8697
+ }
8698
+ function charCodeUnchecked(pos2) {
8699
+ return text.charCodeAt(pos2);
8700
+ }
8701
+ function charCodeChecked(pos2) {
8702
+ return pos2 >= 0 && pos2 < end ? charCodeUnchecked(pos2) : -1 /* EOF */;
8703
+ }
8692
8704
  function error(message, errPos = pos, length3, arg0) {
8693
8705
  if (onError) {
8694
8706
  const oldPos = pos;
@@ -8703,7 +8715,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8703
8715
  let isPreviousTokenSeparator = false;
8704
8716
  let result = "";
8705
8717
  while (true) {
8706
- const ch = text.charCodeAt(pos);
8718
+ const ch = charCodeUnchecked(pos);
8707
8719
  if (ch === 95 /* _ */) {
8708
8720
  tokenFlags |= 512 /* ContainsSeparator */;
8709
8721
  if (allowSeparator) {
@@ -8730,7 +8742,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8730
8742
  }
8731
8743
  break;
8732
8744
  }
8733
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
8745
+ if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
8734
8746
  tokenFlags |= 16384 /* ContainsInvalidSeparator */;
8735
8747
  error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
8736
8748
  }
@@ -8739,9 +8751,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8739
8751
  function scanNumber() {
8740
8752
  let start2 = pos;
8741
8753
  let mainFragment;
8742
- if (text.charCodeAt(pos) === 48 /* _0 */) {
8754
+ if (charCodeUnchecked(pos) === 48 /* _0 */) {
8743
8755
  pos++;
8744
- if (text.charCodeAt(pos) === 95 /* _ */) {
8756
+ if (charCodeUnchecked(pos) === 95 /* _ */) {
8745
8757
  tokenFlags |= 512 /* ContainsSeparator */ | 16384 /* ContainsInvalidSeparator */;
8746
8758
  error(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
8747
8759
  pos--;
@@ -8766,15 +8778,15 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8766
8778
  }
8767
8779
  let decimalFragment;
8768
8780
  let scientificFragment;
8769
- if (text.charCodeAt(pos) === 46 /* dot */) {
8781
+ if (charCodeUnchecked(pos) === 46 /* dot */) {
8770
8782
  pos++;
8771
8783
  decimalFragment = scanNumberFragment();
8772
8784
  }
8773
8785
  let end2 = pos;
8774
- if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) {
8786
+ if (charCodeUnchecked(pos) === 69 /* E */ || charCodeUnchecked(pos) === 101 /* e */) {
8775
8787
  pos++;
8776
8788
  tokenFlags |= 16 /* Scientific */;
8777
- if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */)
8789
+ if (charCodeUnchecked(pos) === 43 /* plus */ || charCodeUnchecked(pos) === 45 /* minus */)
8778
8790
  pos++;
8779
8791
  const preNumericPart = pos;
8780
8792
  const finalFragment = scanNumberFragment();
@@ -8814,7 +8826,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8814
8826
  }
8815
8827
  }
8816
8828
  function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
8817
- if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
8829
+ if (!isIdentifierStart(codePointUnchecked(pos), languageVersion)) {
8818
8830
  return;
8819
8831
  }
8820
8832
  const identifierStart = pos;
@@ -8833,8 +8845,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8833
8845
  function scanDigits() {
8834
8846
  const start2 = pos;
8835
8847
  let isOctal = true;
8836
- while (isDigit(text.charCodeAt(pos))) {
8837
- if (!isOctalDigit(text.charCodeAt(pos))) {
8848
+ while (isDigit(charCodeChecked(pos))) {
8849
+ if (!isOctalDigit(charCodeUnchecked(pos))) {
8838
8850
  isOctal = false;
8839
8851
  }
8840
8852
  pos++;
@@ -8866,7 +8878,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8866
8878
  let allowSeparator = false;
8867
8879
  let isPreviousTokenSeparator = false;
8868
8880
  while (valueChars.length < minCount || scanAsManyAsPossible) {
8869
- let ch = text.charCodeAt(pos);
8881
+ let ch = charCodeUnchecked(pos);
8870
8882
  if (canHaveSeparators && ch === 95 /* _ */) {
8871
8883
  tokenFlags |= 512 /* ContainsSeparator */;
8872
8884
  if (allowSeparator) {
@@ -8893,13 +8905,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8893
8905
  if (valueChars.length < minCount) {
8894
8906
  valueChars = [];
8895
8907
  }
8896
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
8908
+ if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
8897
8909
  error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
8898
8910
  }
8899
8911
  return String.fromCharCode(...valueChars);
8900
8912
  }
8901
8913
  function scanString(jsxAttributeString = false) {
8902
- const quote = text.charCodeAt(pos);
8914
+ const quote = charCodeUnchecked(pos);
8903
8915
  pos++;
8904
8916
  let result = "";
8905
8917
  let start2 = pos;
@@ -8910,7 +8922,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8910
8922
  error(Diagnostics.Unterminated_string_literal);
8911
8923
  break;
8912
8924
  }
8913
- const ch = text.charCodeAt(pos);
8925
+ const ch = charCodeUnchecked(pos);
8914
8926
  if (ch === quote) {
8915
8927
  result += text.substring(start2, pos);
8916
8928
  pos++;
@@ -8938,7 +8950,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8938
8950
  return result;
8939
8951
  }
8940
8952
  function scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError) {
8941
- const startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */;
8953
+ const startedWithBacktick = charCodeUnchecked(pos) === 96 /* backtick */;
8942
8954
  pos++;
8943
8955
  let start2 = pos;
8944
8956
  let contents = "";
@@ -8951,14 +8963,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8951
8963
  resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
8952
8964
  break;
8953
8965
  }
8954
- const currChar = text.charCodeAt(pos);
8966
+ const currChar = charCodeUnchecked(pos);
8955
8967
  if (currChar === 96 /* backtick */) {
8956
8968
  contents += text.substring(start2, pos);
8957
8969
  pos++;
8958
8970
  resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
8959
8971
  break;
8960
8972
  }
8961
- if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) {
8973
+ if (currChar === 36 /* $ */ && pos + 1 < end && charCodeUnchecked(pos + 1) === 123 /* openBrace */) {
8962
8974
  contents += text.substring(start2, pos);
8963
8975
  pos += 2;
8964
8976
  resultingToken = startedWithBacktick ? 16 /* TemplateHead */ : 17 /* TemplateMiddle */;
@@ -8977,7 +8989,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8977
8989
  if (currChar === 13 /* carriageReturn */) {
8978
8990
  contents += text.substring(start2, pos);
8979
8991
  pos++;
8980
- if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
8992
+ if (pos < end && charCodeUnchecked(pos) === 10 /* lineFeed */) {
8981
8993
  pos++;
8982
8994
  }
8983
8995
  contents += "\n";
@@ -8997,24 +9009,24 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8997
9009
  error(Diagnostics.Unexpected_end_of_text);
8998
9010
  return "";
8999
9011
  }
9000
- const ch = text.charCodeAt(pos);
9012
+ const ch = charCodeUnchecked(pos);
9001
9013
  pos++;
9002
9014
  switch (ch) {
9003
9015
  case 48 /* _0 */:
9004
- if (pos >= end || !isDigit(text.charCodeAt(pos))) {
9016
+ if (pos >= end || !isDigit(charCodeUnchecked(pos))) {
9005
9017
  return "\0";
9006
9018
  }
9007
9019
  case 49 /* _1 */:
9008
9020
  case 50 /* _2 */:
9009
9021
  case 51 /* _3 */:
9010
- if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
9022
+ if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
9011
9023
  pos++;
9012
9024
  }
9013
9025
  case 52 /* _4 */:
9014
9026
  case 53 /* _5 */:
9015
9027
  case 54 /* _6 */:
9016
9028
  case 55 /* _7 */:
9017
- if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
9029
+ if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
9018
9030
  pos++;
9019
9031
  }
9020
9032
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
@@ -9051,12 +9063,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9051
9063
  case 34 /* doubleQuote */:
9052
9064
  return '"';
9053
9065
  case 117 /* u */:
9054
- if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
9066
+ if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
9055
9067
  pos -= 2;
9056
9068
  return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
9057
9069
  }
9058
9070
  for (; pos < start2 + 6; pos++) {
9059
- if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
9071
+ if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
9060
9072
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
9061
9073
  if (isRegularExpression || shouldEmitInvalidEscapeError) {
9062
9074
  error(Diagnostics.Hexadecimal_digit_expected);
@@ -9067,11 +9079,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9067
9079
  tokenFlags |= 1024 /* UnicodeEscape */;
9068
9080
  const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
9069
9081
  const escapedValueString = String.fromCharCode(escapedValue);
9070
- if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && text.charCodeAt(pos + 2) !== 123 /* openBrace */) {
9082
+ if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
9071
9083
  const nextStart = pos;
9072
9084
  let nextPos = pos + 2;
9073
9085
  for (; nextPos < nextStart + 6; nextPos++) {
9074
- if (!isHexDigit(text.charCodeAt(pos))) {
9086
+ if (!isHexDigit(charCodeUnchecked(pos))) {
9075
9087
  return escapedValueString;
9076
9088
  }
9077
9089
  }
@@ -9084,7 +9096,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9084
9096
  return escapedValueString;
9085
9097
  case 120 /* x */:
9086
9098
  for (; pos < start2 + 4; pos++) {
9087
- if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
9099
+ if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
9088
9100
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
9089
9101
  if (isRegularExpression || shouldEmitInvalidEscapeError) {
9090
9102
  error(Diagnostics.Hexadecimal_digit_expected);
@@ -9095,7 +9107,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9095
9107
  tokenFlags |= 4096 /* HexEscape */;
9096
9108
  return String.fromCharCode(parseInt(text.substring(start2 + 2, pos), 16));
9097
9109
  case 13 /* carriageReturn */:
9098
- if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
9110
+ if (pos < end && charCodeUnchecked(pos) === 10 /* lineFeed */) {
9099
9111
  pos++;
9100
9112
  }
9101
9113
  case 10 /* lineFeed */:
@@ -9136,7 +9148,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9136
9148
  error(Diagnostics.Unexpected_end_of_text);
9137
9149
  }
9138
9150
  isInvalidExtendedEscape = true;
9139
- } else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
9151
+ } else if (charCodeUnchecked(pos) === 125 /* closeBrace */) {
9140
9152
  pos++;
9141
9153
  } else {
9142
9154
  if (shouldEmitInvalidEscapeError) {
@@ -9152,7 +9164,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9152
9164
  return utf16EncodeAsString(escapedValue);
9153
9165
  }
9154
9166
  function peekUnicodeEscape() {
9155
- if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) {
9167
+ if (pos + 5 < end && charCodeUnchecked(pos + 1) === 117 /* u */) {
9156
9168
  const start2 = pos;
9157
9169
  pos += 2;
9158
9170
  const value = scanExactNumberOfHexDigits(
@@ -9166,7 +9178,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9166
9178
  return -1;
9167
9179
  }
9168
9180
  function peekExtendedUnicodeEscape() {
9169
- if (codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) {
9181
+ if (codePointUnchecked(pos + 1) === 117 /* u */ && codePointUnchecked(pos + 2) === 123 /* openBrace */) {
9170
9182
  const start2 = pos;
9171
9183
  pos += 3;
9172
9184
  const escapedValueString = scanMinimumNumberOfHexDigits(
@@ -9184,7 +9196,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9184
9196
  let result = "";
9185
9197
  let start2 = pos;
9186
9198
  while (pos < end) {
9187
- let ch = codePointAt(text, pos);
9199
+ let ch = codePointUnchecked(pos);
9188
9200
  if (isIdentifierPart(ch, languageVersion)) {
9189
9201
  pos += charSize(ch);
9190
9202
  } else if (ch === 92 /* backslash */) {
@@ -9231,7 +9243,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9231
9243
  let separatorAllowed = false;
9232
9244
  let isPreviousTokenSeparator = false;
9233
9245
  while (true) {
9234
- const ch = text.charCodeAt(pos);
9246
+ const ch = charCodeUnchecked(pos);
9235
9247
  if (ch === 95 /* _ */) {
9236
9248
  tokenFlags |= 512 /* ContainsSeparator */;
9237
9249
  if (separatorAllowed) {
@@ -9253,13 +9265,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9253
9265
  pos++;
9254
9266
  isPreviousTokenSeparator = false;
9255
9267
  }
9256
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
9268
+ if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
9257
9269
  error(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
9258
9270
  }
9259
9271
  return value;
9260
9272
  }
9261
9273
  function checkBigIntSuffix() {
9262
- if (text.charCodeAt(pos) === 110 /* n */) {
9274
+ if (charCodeUnchecked(pos) === 110 /* n */) {
9263
9275
  tokenValue += "n";
9264
9276
  if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) {
9265
9277
  tokenValue = parsePseudoBigInt(tokenValue) + "n";
@@ -9281,7 +9293,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9281
9293
  if (pos >= end) {
9282
9294
  return token = 1 /* EndOfFileToken */;
9283
9295
  }
9284
- const ch = codePointAt(text, pos);
9296
+ const ch = codePointUnchecked(pos);
9285
9297
  if (pos === 0) {
9286
9298
  if (ch === 35 /* hash */ && isShebangTrivia(text, pos)) {
9287
9299
  pos = scanShebangTrivia(text, pos);
@@ -9300,7 +9312,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9300
9312
  pos++;
9301
9313
  continue;
9302
9314
  } else {
9303
- if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
9315
+ if (ch === 13 /* carriageReturn */ && pos + 1 < end && charCodeUnchecked(pos + 1) === 10 /* lineFeed */) {
9304
9316
  pos += 2;
9305
9317
  } else {
9306
9318
  pos++;
@@ -9333,14 +9345,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9333
9345
  pos++;
9334
9346
  continue;
9335
9347
  } else {
9336
- while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
9348
+ while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
9337
9349
  pos++;
9338
9350
  }
9339
9351
  return token = 5 /* WhitespaceTrivia */;
9340
9352
  }
9341
9353
  case 33 /* exclamation */:
9342
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9343
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9354
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9355
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9344
9356
  return pos += 3, token = 38 /* ExclamationEqualsEqualsToken */;
9345
9357
  }
9346
9358
  return pos += 2, token = 36 /* ExclamationEqualsToken */;
@@ -9357,19 +9369,19 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9357
9369
  false
9358
9370
  );
9359
9371
  case 37 /* percent */:
9360
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9372
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9361
9373
  return pos += 2, token = 70 /* PercentEqualsToken */;
9362
9374
  }
9363
9375
  pos++;
9364
9376
  return token = 45 /* PercentToken */;
9365
9377
  case 38 /* ampersand */:
9366
- if (text.charCodeAt(pos + 1) === 38 /* ampersand */) {
9367
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9378
+ if (charCodeUnchecked(pos + 1) === 38 /* ampersand */) {
9379
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9368
9380
  return pos += 3, token = 77 /* AmpersandAmpersandEqualsToken */;
9369
9381
  }
9370
9382
  return pos += 2, token = 56 /* AmpersandAmpersandToken */;
9371
9383
  }
9372
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9384
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9373
9385
  return pos += 2, token = 74 /* AmpersandEqualsToken */;
9374
9386
  }
9375
9387
  pos++;
@@ -9381,11 +9393,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9381
9393
  pos++;
9382
9394
  return token = 22 /* CloseParenToken */;
9383
9395
  case 42 /* asterisk */:
9384
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9396
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9385
9397
  return pos += 2, token = 67 /* AsteriskEqualsToken */;
9386
9398
  }
9387
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
9388
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9399
+ if (charCodeUnchecked(pos + 1) === 42 /* asterisk */) {
9400
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9389
9401
  return pos += 3, token = 68 /* AsteriskAsteriskEqualsToken */;
9390
9402
  }
9391
9403
  return pos += 2, token = 43 /* AsteriskAsteriskToken */;
@@ -9397,10 +9409,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9397
9409
  }
9398
9410
  return token = 42 /* AsteriskToken */;
9399
9411
  case 43 /* plus */:
9400
- if (text.charCodeAt(pos + 1) === 43 /* plus */) {
9412
+ if (charCodeUnchecked(pos + 1) === 43 /* plus */) {
9401
9413
  return pos += 2, token = 46 /* PlusPlusToken */;
9402
9414
  }
9403
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9415
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9404
9416
  return pos += 2, token = 65 /* PlusEqualsToken */;
9405
9417
  }
9406
9418
  pos++;
@@ -9409,29 +9421,29 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9409
9421
  pos++;
9410
9422
  return token = 28 /* CommaToken */;
9411
9423
  case 45 /* minus */:
9412
- if (text.charCodeAt(pos + 1) === 45 /* minus */) {
9424
+ if (charCodeUnchecked(pos + 1) === 45 /* minus */) {
9413
9425
  return pos += 2, token = 47 /* MinusMinusToken */;
9414
9426
  }
9415
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9427
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9416
9428
  return pos += 2, token = 66 /* MinusEqualsToken */;
9417
9429
  }
9418
9430
  pos++;
9419
9431
  return token = 41 /* MinusToken */;
9420
9432
  case 46 /* dot */:
9421
- if (isDigit(text.charCodeAt(pos + 1))) {
9433
+ if (isDigit(charCodeUnchecked(pos + 1))) {
9422
9434
  scanNumber();
9423
9435
  return token = 9 /* NumericLiteral */;
9424
9436
  }
9425
- if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) {
9437
+ if (charCodeUnchecked(pos + 1) === 46 /* dot */ && charCodeUnchecked(pos + 2) === 46 /* dot */) {
9426
9438
  return pos += 3, token = 26 /* DotDotDotToken */;
9427
9439
  }
9428
9440
  pos++;
9429
9441
  return token = 25 /* DotToken */;
9430
9442
  case 47 /* slash */:
9431
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
9443
+ if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
9432
9444
  pos += 2;
9433
9445
  while (pos < end) {
9434
- if (isLineBreak(text.charCodeAt(pos))) {
9446
+ if (isLineBreak(charCodeUnchecked(pos))) {
9435
9447
  break;
9436
9448
  }
9437
9449
  pos++;
@@ -9448,14 +9460,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9448
9460
  return token = 2 /* SingleLineCommentTrivia */;
9449
9461
  }
9450
9462
  }
9451
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
9463
+ if (charCodeUnchecked(pos + 1) === 42 /* asterisk */) {
9452
9464
  pos += 2;
9453
- const isJSDoc2 = text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */;
9465
+ const isJSDoc2 = charCodeUnchecked(pos) === 42 /* asterisk */ && charCodeUnchecked(pos + 1) !== 47 /* slash */;
9454
9466
  let commentClosed = false;
9455
9467
  let lastLineStart = tokenStart;
9456
9468
  while (pos < end) {
9457
- const ch2 = text.charCodeAt(pos);
9458
- if (ch2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
9469
+ const ch2 = charCodeUnchecked(pos);
9470
+ if (ch2 === 42 /* asterisk */ && charCodeUnchecked(pos + 1) === 47 /* slash */) {
9459
9471
  pos += 2;
9460
9472
  commentClosed = true;
9461
9473
  break;
@@ -9482,13 +9494,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9482
9494
  return token = 3 /* MultiLineCommentTrivia */;
9483
9495
  }
9484
9496
  }
9485
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9497
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9486
9498
  return pos += 2, token = 69 /* SlashEqualsToken */;
9487
9499
  }
9488
9500
  pos++;
9489
9501
  return token = 44 /* SlashToken */;
9490
9502
  case 48 /* _0 */:
9491
- if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) {
9503
+ if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 88 /* X */ || charCodeUnchecked(pos + 1) === 120 /* x */)) {
9492
9504
  pos += 2;
9493
9505
  tokenValue = scanMinimumNumberOfHexDigits(
9494
9506
  1,
@@ -9502,7 +9514,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9502
9514
  tokenValue = "0x" + tokenValue;
9503
9515
  tokenFlags |= 64 /* HexSpecifier */;
9504
9516
  return token = checkBigIntSuffix();
9505
- } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) {
9517
+ } else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 66 /* B */ || charCodeUnchecked(pos + 1) === 98 /* b */)) {
9506
9518
  pos += 2;
9507
9519
  tokenValue = scanBinaryOrOctalDigits(
9508
9520
  /* base */
@@ -9515,7 +9527,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9515
9527
  tokenValue = "0b" + tokenValue;
9516
9528
  tokenFlags |= 128 /* BinarySpecifier */;
9517
9529
  return token = checkBigIntSuffix();
9518
- } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) {
9530
+ } else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 79 /* O */ || charCodeUnchecked(pos + 1) === 111 /* o */)) {
9519
9531
  pos += 2;
9520
9532
  tokenValue = scanBinaryOrOctalDigits(
9521
9533
  /* base */
@@ -9554,16 +9566,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9554
9566
  return token = 7 /* ConflictMarkerTrivia */;
9555
9567
  }
9556
9568
  }
9557
- if (text.charCodeAt(pos + 1) === 60 /* lessThan */) {
9558
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9569
+ if (charCodeUnchecked(pos + 1) === 60 /* lessThan */) {
9570
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9559
9571
  return pos += 3, token = 71 /* LessThanLessThanEqualsToken */;
9560
9572
  }
9561
9573
  return pos += 2, token = 48 /* LessThanLessThanToken */;
9562
9574
  }
9563
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9575
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9564
9576
  return pos += 2, token = 33 /* LessThanEqualsToken */;
9565
9577
  }
9566
- if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) {
9578
+ if (languageVariant === 1 /* JSX */ && charCodeUnchecked(pos + 1) === 47 /* slash */ && charCodeUnchecked(pos + 2) !== 42 /* asterisk */) {
9567
9579
  return pos += 2, token = 31 /* LessThanSlashToken */;
9568
9580
  }
9569
9581
  pos++;
@@ -9577,13 +9589,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9577
9589
  return token = 7 /* ConflictMarkerTrivia */;
9578
9590
  }
9579
9591
  }
9580
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9581
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9592
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9593
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9582
9594
  return pos += 3, token = 37 /* EqualsEqualsEqualsToken */;
9583
9595
  }
9584
9596
  return pos += 2, token = 35 /* EqualsEqualsToken */;
9585
9597
  }
9586
- if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
9598
+ if (charCodeUnchecked(pos + 1) === 62 /* greaterThan */) {
9587
9599
  return pos += 2, token = 39 /* EqualsGreaterThanToken */;
9588
9600
  }
9589
9601
  pos++;
@@ -9600,11 +9612,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9600
9612
  pos++;
9601
9613
  return token = 32 /* GreaterThanToken */;
9602
9614
  case 63 /* question */:
9603
- if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) {
9615
+ if (charCodeUnchecked(pos + 1) === 46 /* dot */ && !isDigit(charCodeUnchecked(pos + 2))) {
9604
9616
  return pos += 2, token = 29 /* QuestionDotToken */;
9605
9617
  }
9606
- if (text.charCodeAt(pos + 1) === 63 /* question */) {
9607
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9618
+ if (charCodeUnchecked(pos + 1) === 63 /* question */) {
9619
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9608
9620
  return pos += 3, token = 78 /* QuestionQuestionEqualsToken */;
9609
9621
  }
9610
9622
  return pos += 2, token = 61 /* QuestionQuestionToken */;
@@ -9618,7 +9630,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9618
9630
  pos++;
9619
9631
  return token = 24 /* CloseBracketToken */;
9620
9632
  case 94 /* caret */:
9621
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9633
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9622
9634
  return pos += 2, token = 79 /* CaretEqualsToken */;
9623
9635
  }
9624
9636
  pos++;
@@ -9635,13 +9647,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9635
9647
  return token = 7 /* ConflictMarkerTrivia */;
9636
9648
  }
9637
9649
  }
9638
- if (text.charCodeAt(pos + 1) === 124 /* bar */) {
9639
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9650
+ if (charCodeUnchecked(pos + 1) === 124 /* bar */) {
9651
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9640
9652
  return pos += 3, token = 76 /* BarBarEqualsToken */;
9641
9653
  }
9642
9654
  return pos += 2, token = 57 /* BarBarToken */;
9643
9655
  }
9644
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9656
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9645
9657
  return pos += 2, token = 75 /* BarEqualsToken */;
9646
9658
  }
9647
9659
  pos++;
@@ -9680,7 +9692,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9680
9692
  pos++;
9681
9693
  return token = 0 /* Unknown */;
9682
9694
  }
9683
- const charAfterHash = codePointAt(text, pos + 1);
9695
+ const charAfterHash = codePointUnchecked(pos + 1);
9684
9696
  if (charAfterHash === 92 /* backslash */) {
9685
9697
  pos++;
9686
9698
  const extendedCookedChar2 = peekExtendedUnicodeEscape();
@@ -9750,7 +9762,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9750
9762
  Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
9751
9763
  pos = tokenStart = fullStartPos;
9752
9764
  tokenFlags = 0;
9753
- const ch = codePointAt(text, pos);
9765
+ const ch = codePointUnchecked(pos);
9754
9766
  const identifierKind = scanIdentifier(ch, 99 /* ESNext */);
9755
9767
  if (identifierKind) {
9756
9768
  return token = identifierKind;
@@ -9762,7 +9774,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9762
9774
  let ch = startCharacter;
9763
9775
  if (isIdentifierStart(ch, languageVersion2)) {
9764
9776
  pos += charSize(ch);
9765
- while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion2))
9777
+ while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos), languageVersion2))
9766
9778
  pos += charSize(ch);
9767
9779
  tokenValue = text.substring(tokenStart, pos);
9768
9780
  if (ch === 92 /* backslash */) {
@@ -9773,20 +9785,20 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9773
9785
  }
9774
9786
  function reScanGreaterToken() {
9775
9787
  if (token === 32 /* GreaterThanToken */) {
9776
- if (text.charCodeAt(pos) === 62 /* greaterThan */) {
9777
- if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
9778
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
9788
+ if (charCodeUnchecked(pos) === 62 /* greaterThan */) {
9789
+ if (charCodeUnchecked(pos + 1) === 62 /* greaterThan */) {
9790
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
9779
9791
  return pos += 3, token = 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
9780
9792
  }
9781
9793
  return pos += 2, token = 50 /* GreaterThanGreaterThanGreaterThanToken */;
9782
9794
  }
9783
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
9795
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
9784
9796
  return pos += 2, token = 72 /* GreaterThanGreaterThanEqualsToken */;
9785
9797
  }
9786
9798
  pos++;
9787
9799
  return token = 49 /* GreaterThanGreaterThanToken */;
9788
9800
  }
9789
- if (text.charCodeAt(pos) === 61 /* equals */) {
9801
+ if (charCodeUnchecked(pos) === 61 /* equals */) {
9790
9802
  pos++;
9791
9803
  return token = 34 /* GreaterThanEqualsToken */;
9792
9804
  }
@@ -9809,7 +9821,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9809
9821
  error(Diagnostics.Unterminated_regular_expression_literal);
9810
9822
  break;
9811
9823
  }
9812
- const ch = text.charCodeAt(p);
9824
+ const ch = charCodeUnchecked(p);
9813
9825
  if (isLineBreak(ch)) {
9814
9826
  tokenFlags |= 4 /* Unterminated */;
9815
9827
  error(Diagnostics.Unterminated_regular_expression_literal);
@@ -9833,7 +9845,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9833
9845
  const endOfBody = p - (isUnterminated ? 0 : 1);
9834
9846
  let regExpFlags = 0 /* None */;
9835
9847
  while (p < end) {
9836
- const ch = text.charCodeAt(p);
9848
+ const ch = charCodeUnchecked(p);
9837
9849
  if (!isIdentifierPart(ch, languageVersion)) {
9838
9850
  break;
9839
9851
  }
@@ -9852,845 +9864,860 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9852
9864
  }
9853
9865
  p++;
9854
9866
  }
9867
+ pos = p;
9855
9868
  if (reportErrors2) {
9856
- pos = tokenStart + 1;
9857
- const saveTokenPos = tokenStart;
9869
+ const saveTokenStart = tokenStart;
9858
9870
  const saveTokenFlags = tokenFlags;
9871
+ const savePos = pos;
9872
+ const saveEnd = end;
9873
+ pos = tokenStart + 1;
9874
+ end = endOfBody;
9859
9875
  scanRegularExpressionWorker(
9860
- text,
9861
- endOfBody,
9862
9876
  regExpFlags,
9863
9877
  isUnterminated,
9864
9878
  /*annexB*/
9865
9879
  true
9866
9880
  );
9867
- if (!isUnterminated) {
9868
- pos = p;
9869
- }
9870
- tokenStart = saveTokenPos;
9881
+ tokenStart = saveTokenStart;
9871
9882
  tokenFlags = saveTokenFlags;
9872
- } else {
9873
- pos = p;
9883
+ pos = savePos;
9884
+ end = saveEnd;
9874
9885
  }
9875
9886
  tokenValue = text.substring(tokenStart, pos);
9876
9887
  token = 14 /* RegularExpressionLiteral */;
9877
9888
  }
9878
9889
  return token;
9879
- function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated, annexB) {
9880
- const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
9881
- const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
9882
- if (unicodeMode) {
9883
- annexB = false;
9884
- }
9885
- let mayContainStrings = false;
9886
- let numberOfCapturingGroups = 0;
9887
- const groupSpecifiers = /* @__PURE__ */ new Set();
9888
- const groupNameReferences = [];
9889
- const decimalEscapes = [];
9890
- const namedCapturingGroups = [];
9891
- function scanDisjunction(isInGroup) {
9892
- while (true) {
9893
- namedCapturingGroups.push(/* @__PURE__ */ new Set());
9894
- scanAlternative(isInGroup);
9895
- namedCapturingGroups.pop();
9896
- if (text2.charCodeAt(pos) !== 124 /* bar */) {
9897
- return;
9898
- }
9899
- pos++;
9890
+ }
9891
+ function scanRegularExpressionWorker(regExpFlags, isUnterminated, annexB) {
9892
+ var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
9893
+ var unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
9894
+ if (unicodeMode) {
9895
+ annexB = false;
9896
+ }
9897
+ var mayContainStrings = false;
9898
+ var numberOfCapturingGroups = 0;
9899
+ var groupSpecifiers;
9900
+ var groupNameReferences;
9901
+ var decimalEscapes;
9902
+ var namedCapturingGroupsScopeStack = [];
9903
+ var topNamedCapturingGroupsScope;
9904
+ function scanDisjunction(isInGroup) {
9905
+ while (true) {
9906
+ namedCapturingGroupsScopeStack.push(topNamedCapturingGroupsScope);
9907
+ topNamedCapturingGroupsScope = void 0;
9908
+ scanAlternative(isInGroup);
9909
+ topNamedCapturingGroupsScope = namedCapturingGroupsScopeStack.pop();
9910
+ if (charCodeChecked(pos) !== 124 /* bar */) {
9911
+ return;
9900
9912
  }
9913
+ pos++;
9901
9914
  }
9902
- function scanAlternative(isInGroup) {
9903
- let isPreviousTermQuantifiable = false;
9904
- while (pos < end2) {
9905
- const start2 = pos;
9906
- const ch = text2.charCodeAt(pos);
9907
- switch (ch) {
9908
- case 94 /* caret */:
9909
- case 36 /* $ */:
9910
- pos++;
9911
- isPreviousTermQuantifiable = false;
9912
- break;
9913
- case 92 /* backslash */:
9915
+ }
9916
+ function scanAlternative(isInGroup) {
9917
+ let isPreviousTermQuantifiable = false;
9918
+ while (true) {
9919
+ const start2 = pos;
9920
+ const ch = charCodeChecked(pos);
9921
+ switch (ch) {
9922
+ case -1 /* EOF */:
9923
+ return;
9924
+ case 94 /* caret */:
9925
+ case 36 /* $ */:
9926
+ pos++;
9927
+ isPreviousTermQuantifiable = false;
9928
+ break;
9929
+ case 92 /* backslash */:
9930
+ pos++;
9931
+ switch (charCodeChecked(pos)) {
9932
+ case 98 /* b */:
9933
+ case 66 /* B */:
9934
+ pos++;
9935
+ isPreviousTermQuantifiable = false;
9936
+ break;
9937
+ default:
9938
+ scanAtomEscape();
9939
+ isPreviousTermQuantifiable = true;
9940
+ break;
9941
+ }
9942
+ break;
9943
+ case 40 /* openParen */:
9944
+ pos++;
9945
+ if (charCodeChecked(pos) === 63 /* question */) {
9914
9946
  pos++;
9915
- switch (text2.charCodeAt(pos)) {
9916
- case 98 /* b */:
9917
- case 66 /* B */:
9947
+ switch (charCodeChecked(pos)) {
9948
+ case 61 /* equals */:
9949
+ case 33 /* exclamation */:
9918
9950
  pos++;
9919
- isPreviousTermQuantifiable = false;
9920
- break;
9921
- default:
9922
- scanAtomEscape();
9923
- isPreviousTermQuantifiable = true;
9951
+ isPreviousTermQuantifiable = annexB;
9924
9952
  break;
9925
- }
9926
- break;
9927
- case 40 /* openParen */:
9928
- pos++;
9929
- if (text2.charCodeAt(pos) === 63 /* question */) {
9930
- pos++;
9931
- switch (text2.charCodeAt(pos)) {
9932
- case 61 /* equals */:
9933
- case 33 /* exclamation */:
9934
- pos++;
9935
- isPreviousTermQuantifiable = annexB;
9936
- break;
9937
- case 60 /* lessThan */:
9938
- const groupNameStart = pos;
9939
- pos++;
9940
- switch (text2.charCodeAt(pos)) {
9941
- case 61 /* equals */:
9942
- case 33 /* exclamation */:
9943
- pos++;
9944
- isPreviousTermQuantifiable = false;
9945
- break;
9946
- default:
9947
- scanGroupName(
9948
- /*isReference*/
9949
- false
9950
- );
9951
- scanExpectedChar(62 /* greaterThan */);
9952
- if (languageVersion < 5 /* ES2018 */) {
9953
- error(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
9954
- }
9955
- numberOfCapturingGroups++;
9956
- isPreviousTermQuantifiable = true;
9957
- break;
9958
- }
9959
- break;
9960
- default:
9961
- const start3 = pos;
9962
- const setFlags = scanPatternModifiers(0 /* None */);
9963
- if (text2.charCodeAt(pos) === 45 /* minus */) {
9953
+ case 60 /* lessThan */:
9954
+ const groupNameStart = pos;
9955
+ pos++;
9956
+ switch (charCodeChecked(pos)) {
9957
+ case 61 /* equals */:
9958
+ case 33 /* exclamation */:
9964
9959
  pos++;
9965
- scanPatternModifiers(setFlags);
9966
- if (pos === start3 + 1) {
9967
- error(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
9960
+ isPreviousTermQuantifiable = false;
9961
+ break;
9962
+ default:
9963
+ scanGroupName(
9964
+ /*isReference*/
9965
+ false
9966
+ );
9967
+ scanExpectedChar(62 /* greaterThan */);
9968
+ if (languageVersion < 5 /* ES2018 */) {
9969
+ error(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
9968
9970
  }
9971
+ numberOfCapturingGroups++;
9972
+ isPreviousTermQuantifiable = true;
9973
+ break;
9974
+ }
9975
+ break;
9976
+ default:
9977
+ const start3 = pos;
9978
+ const setFlags = scanPatternModifiers(0 /* None */);
9979
+ if (charCodeChecked(pos) === 45 /* minus */) {
9980
+ pos++;
9981
+ scanPatternModifiers(setFlags);
9982
+ if (pos === start3 + 1) {
9983
+ error(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
9969
9984
  }
9970
- scanExpectedChar(58 /* colon */);
9971
- isPreviousTermQuantifiable = true;
9972
- break;
9973
- }
9974
- } else {
9975
- numberOfCapturingGroups++;
9976
- isPreviousTermQuantifiable = true;
9985
+ }
9986
+ scanExpectedChar(58 /* colon */);
9987
+ isPreviousTermQuantifiable = true;
9988
+ break;
9977
9989
  }
9978
- scanDisjunction(
9979
- /*isInGroup*/
9980
- true
9981
- );
9982
- scanExpectedChar(41 /* closeParen */);
9983
- break;
9984
- case 123 /* openBrace */:
9990
+ } else {
9991
+ numberOfCapturingGroups++;
9992
+ isPreviousTermQuantifiable = true;
9993
+ }
9994
+ scanDisjunction(
9995
+ /*isInGroup*/
9996
+ true
9997
+ );
9998
+ scanExpectedChar(41 /* closeParen */);
9999
+ break;
10000
+ case 123 /* openBrace */:
10001
+ pos++;
10002
+ const digitsStart = pos;
10003
+ scanDigits();
10004
+ const min2 = tokenValue;
10005
+ if (charCodeChecked(pos) === 44 /* comma */) {
9985
10006
  pos++;
9986
- const digitsStart = pos;
9987
10007
  scanDigits();
9988
- const min2 = tokenValue;
9989
- if (text2.charCodeAt(pos) === 44 /* comma */) {
9990
- pos++;
9991
- scanDigits();
9992
- const max = tokenValue;
9993
- if (!min2) {
9994
- if (max || text2.charCodeAt(pos) === 125 /* closeBrace */) {
9995
- error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
9996
- } else {
9997
- if (unicodeMode) {
9998
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
9999
- }
10000
- isPreviousTermQuantifiable = true;
10001
- break;
10008
+ const max = tokenValue;
10009
+ if (!min2) {
10010
+ if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
10011
+ error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
10012
+ } else {
10013
+ if (unicodeMode) {
10014
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
10002
10015
  }
10016
+ isPreviousTermQuantifiable = true;
10017
+ break;
10003
10018
  }
10004
- if (max && Number.parseInt(min2) > Number.parseInt(max)) {
10005
- error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
10006
- }
10007
- } else if (!min2) {
10008
- if (unicodeMode) {
10009
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
10010
- }
10011
- isPreviousTermQuantifiable = true;
10012
- break;
10013
10019
  }
10014
- scanExpectedChar(125 /* closeBrace */);
10015
- pos--;
10016
- case 42 /* asterisk */:
10017
- case 43 /* plus */:
10018
- case 63 /* question */:
10019
- pos++;
10020
- if (text2.charCodeAt(pos) === 63 /* question */) {
10021
- pos++;
10020
+ if (max && Number.parseInt(min2) > Number.parseInt(max)) {
10021
+ error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
10022
10022
  }
10023
- if (!isPreviousTermQuantifiable) {
10024
- error(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
10025
- }
10026
- isPreviousTermQuantifiable = false;
10027
- break;
10028
- case 46 /* dot */:
10029
- pos++;
10030
- isPreviousTermQuantifiable = true;
10031
- break;
10032
- case 91 /* openBracket */:
10033
- pos++;
10034
- if (unicodeSetsMode) {
10035
- scanClassSetExpression();
10036
- } else {
10037
- scanClassRanges();
10023
+ } else if (!min2) {
10024
+ if (unicodeMode) {
10025
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
10038
10026
  }
10039
- scanExpectedChar(93 /* closeBracket */);
10040
10027
  isPreviousTermQuantifiable = true;
10041
10028
  break;
10042
- case 41 /* closeParen */:
10043
- if (isInGroup) {
10044
- return;
10045
- }
10046
- case 93 /* closeBracket */:
10047
- case 125 /* closeBrace */:
10048
- if (isUnterminated && !isInGroup) {
10049
- return;
10050
- }
10051
- if (unicodeMode || ch === 41 /* closeParen */) {
10052
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10053
- }
10054
- pos++;
10055
- isPreviousTermQuantifiable = true;
10056
- break;
10057
- case 47 /* slash */:
10058
- case 124 /* bar */:
10059
- return;
10060
- default:
10061
- scanSourceCharacter();
10062
- isPreviousTermQuantifiable = true;
10063
- break;
10064
- }
10065
- }
10066
- }
10067
- function scanPatternModifiers(currFlags) {
10068
- while (pos < end2) {
10069
- const ch = text2.charCodeAt(pos);
10070
- if (!isIdentifierPart(ch, languageVersion)) {
10071
- break;
10072
- }
10073
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
10074
- if (flag === void 0) {
10075
- error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
10076
- } else if (currFlags & flag) {
10077
- error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
10078
- } else if (!(flag & 28 /* Modifiers */)) {
10079
- error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
10080
- } else {
10081
- currFlags |= flag;
10082
- checkRegularExpressionFlagAvailable(flag, pos);
10083
- }
10084
- pos++;
10085
- }
10086
- return currFlags;
10087
- }
10088
- function scanAtomEscape() {
10089
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
10090
- switch (text2.charCodeAt(pos)) {
10091
- case 107 /* k */:
10029
+ }
10030
+ scanExpectedChar(125 /* closeBrace */);
10031
+ pos--;
10032
+ case 42 /* asterisk */:
10033
+ case 43 /* plus */:
10034
+ case 63 /* question */:
10092
10035
  pos++;
10093
- if (text2.charCodeAt(pos) === 60 /* lessThan */) {
10036
+ if (charCodeChecked(pos) === 63 /* question */) {
10094
10037
  pos++;
10095
- scanGroupName(
10096
- /*isReference*/
10097
- true
10098
- );
10099
- scanExpectedChar(62 /* greaterThan */);
10100
- } else if (unicodeMode) {
10101
- error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
10102
10038
  }
10103
- break;
10104
- case 113 /* q */:
10105
- if (unicodeSetsMode) {
10106
- pos++;
10107
- error(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
10108
- break;
10039
+ if (!isPreviousTermQuantifiable) {
10040
+ error(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
10109
10041
  }
10110
- default:
10111
- Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
10112
- /*atomEscape*/
10113
- true
10114
- ));
10042
+ isPreviousTermQuantifiable = false;
10115
10043
  break;
10116
- }
10117
- }
10118
- function scanDecimalEscape() {
10119
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
10120
- const ch = text2.charCodeAt(pos);
10121
- if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
10122
- const start2 = pos;
10123
- scanDigits();
10124
- decimalEscapes.push({ pos: start2, end: pos, value: +tokenValue });
10125
- return true;
10126
- }
10127
- return false;
10128
- }
10129
- function scanCharacterEscape(atomEscape) {
10130
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
10131
- let ch = text2.charCodeAt(pos);
10132
- switch (ch) {
10133
- case 99 /* c */:
10044
+ case 46 /* dot */:
10134
10045
  pos++;
10135
- ch = text2.charCodeAt(pos);
10136
- if (isASCIILetter(ch)) {
10137
- pos++;
10138
- return String.fromCharCode(ch & 31);
10139
- }
10140
- if (unicodeMode) {
10141
- error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
10142
- } else if (atomEscape && annexB) {
10143
- pos--;
10144
- return "\\";
10046
+ isPreviousTermQuantifiable = true;
10047
+ break;
10048
+ case 91 /* openBracket */:
10049
+ pos++;
10050
+ if (unicodeSetsMode) {
10051
+ scanClassSetExpression();
10052
+ } else {
10053
+ scanClassRanges();
10145
10054
  }
10146
- return String.fromCharCode(ch);
10147
- case 94 /* caret */:
10148
- case 36 /* $ */:
10149
- case 47 /* slash */:
10150
- case 92 /* backslash */:
10151
- case 46 /* dot */:
10152
- case 42 /* asterisk */:
10153
- case 43 /* plus */:
10154
- case 63 /* question */:
10155
- case 40 /* openParen */:
10055
+ scanExpectedChar(93 /* closeBracket */);
10056
+ isPreviousTermQuantifiable = true;
10057
+ break;
10156
10058
  case 41 /* closeParen */:
10157
- case 91 /* openBracket */:
10059
+ if (isInGroup) {
10060
+ return;
10061
+ }
10158
10062
  case 93 /* closeBracket */:
10159
- case 123 /* openBrace */:
10160
10063
  case 125 /* closeBrace */:
10161
- case 124 /* bar */:
10064
+ if (isUnterminated && !isInGroup) {
10065
+ return;
10066
+ }
10067
+ if (unicodeMode || ch === 41 /* closeParen */) {
10068
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10069
+ }
10162
10070
  pos++;
10163
- return String.fromCharCode(ch);
10071
+ isPreviousTermQuantifiable = true;
10072
+ break;
10073
+ case 47 /* slash */:
10074
+ case 124 /* bar */:
10075
+ return;
10164
10076
  default:
10165
- if (pos >= end2) {
10166
- error(Diagnostics.Undetermined_character_escape, pos - 1, 1, ch);
10167
- return "\\";
10168
- }
10169
- pos--;
10170
- return scanEscapeSequence(
10171
- /*shouldEmitInvalidEscapeError*/
10172
- unicodeMode,
10173
- /*isRegularExpression*/
10174
- annexB ? "annex-b" : true
10175
- );
10077
+ scanSourceCharacter();
10078
+ isPreviousTermQuantifiable = true;
10079
+ break;
10176
10080
  }
10177
10081
  }
10178
- function scanGroupName(isReference) {
10179
- Debug.assertEqual(text2.charCodeAt(pos - 1), 60 /* lessThan */);
10180
- tokenStart = pos;
10181
- scanIdentifier(codePointAt(text2, pos), languageVersion);
10182
- if (pos === tokenStart) {
10183
- error(Diagnostics.Expected_a_capturing_group_name);
10184
- } else if (isReference) {
10185
- groupNameReferences.push({ pos: tokenStart, end: pos, name: tokenValue });
10186
- } else if (namedCapturingGroups.some((group2) => group2.has(tokenValue))) {
10187
- error(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
10082
+ }
10083
+ function scanPatternModifiers(currFlags) {
10084
+ while (true) {
10085
+ const ch = charCodeChecked(pos);
10086
+ if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
10087
+ break;
10088
+ }
10089
+ const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
10090
+ if (flag === void 0) {
10091
+ error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
10092
+ } else if (currFlags & flag) {
10093
+ error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
10094
+ } else if (!(flag & 28 /* Modifiers */)) {
10095
+ error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
10188
10096
  } else {
10189
- last(namedCapturingGroups).add(tokenValue);
10190
- groupSpecifiers.add(tokenValue);
10097
+ currFlags |= flag;
10098
+ checkRegularExpressionFlagAvailable(flag, pos);
10191
10099
  }
10100
+ pos++;
10101
+ }
10102
+ return currFlags;
10103
+ }
10104
+ function scanAtomEscape() {
10105
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
10106
+ switch (charCodeChecked(pos)) {
10107
+ case 107 /* k */:
10108
+ pos++;
10109
+ if (charCodeChecked(pos) === 60 /* lessThan */) {
10110
+ pos++;
10111
+ scanGroupName(
10112
+ /*isReference*/
10113
+ true
10114
+ );
10115
+ scanExpectedChar(62 /* greaterThan */);
10116
+ } else if (unicodeMode) {
10117
+ error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
10118
+ }
10119
+ break;
10120
+ case 113 /* q */:
10121
+ if (unicodeSetsMode) {
10122
+ pos++;
10123
+ error(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
10124
+ break;
10125
+ }
10126
+ default:
10127
+ Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
10128
+ /*atomEscape*/
10129
+ true
10130
+ ));
10131
+ break;
10132
+ }
10133
+ }
10134
+ function scanDecimalEscape() {
10135
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
10136
+ const ch = charCodeChecked(pos);
10137
+ if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
10138
+ const start2 = pos;
10139
+ scanDigits();
10140
+ decimalEscapes = append(decimalEscapes, { pos: start2, end: pos, value: +tokenValue });
10141
+ return true;
10142
+ }
10143
+ return false;
10144
+ }
10145
+ function scanCharacterEscape(atomEscape) {
10146
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
10147
+ let ch = charCodeChecked(pos);
10148
+ switch (ch) {
10149
+ case 99 /* c */:
10150
+ pos++;
10151
+ ch = charCodeChecked(pos);
10152
+ if (isASCIILetter(ch)) {
10153
+ pos++;
10154
+ return String.fromCharCode(ch & 31);
10155
+ }
10156
+ if (unicodeMode) {
10157
+ error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
10158
+ } else if (atomEscape && annexB) {
10159
+ pos--;
10160
+ return "\\";
10161
+ }
10162
+ return String.fromCharCode(ch);
10163
+ case 94 /* caret */:
10164
+ case 36 /* $ */:
10165
+ case 47 /* slash */:
10166
+ case 92 /* backslash */:
10167
+ case 46 /* dot */:
10168
+ case 42 /* asterisk */:
10169
+ case 43 /* plus */:
10170
+ case 63 /* question */:
10171
+ case 40 /* openParen */:
10172
+ case 41 /* closeParen */:
10173
+ case 91 /* openBracket */:
10174
+ case 93 /* closeBracket */:
10175
+ case 123 /* openBrace */:
10176
+ case 125 /* closeBrace */:
10177
+ case 124 /* bar */:
10178
+ pos++;
10179
+ return String.fromCharCode(ch);
10180
+ default:
10181
+ if (pos >= end) {
10182
+ error(Diagnostics.Undetermined_character_escape, pos - 1, 1);
10183
+ return "\\";
10184
+ }
10185
+ pos--;
10186
+ return scanEscapeSequence(
10187
+ /*shouldEmitInvalidEscapeError*/
10188
+ unicodeMode,
10189
+ /*isRegularExpression*/
10190
+ annexB ? "annex-b" : true
10191
+ );
10192
10192
  }
10193
- function isClassContentExit(ch) {
10194
- return ch === 93 /* closeBracket */ || pos >= end2;
10193
+ }
10194
+ function scanGroupName(isReference) {
10195
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 60 /* lessThan */);
10196
+ tokenStart = pos;
10197
+ scanIdentifier(codePointChecked(pos), languageVersion);
10198
+ if (pos === tokenStart) {
10199
+ error(Diagnostics.Expected_a_capturing_group_name);
10200
+ } else if (isReference) {
10201
+ groupNameReferences = append(groupNameReferences, { pos: tokenStart, end: pos, name: tokenValue });
10202
+ } else if ((topNamedCapturingGroupsScope == null ? void 0 : topNamedCapturingGroupsScope.has(tokenValue)) || namedCapturingGroupsScopeStack.some((group2) => group2 == null ? void 0 : group2.has(tokenValue))) {
10203
+ error(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
10204
+ } else {
10205
+ topNamedCapturingGroupsScope ?? (topNamedCapturingGroupsScope = /* @__PURE__ */ new Set());
10206
+ topNamedCapturingGroupsScope.add(tokenValue);
10207
+ groupSpecifiers ?? (groupSpecifiers = /* @__PURE__ */ new Set());
10208
+ groupSpecifiers.add(tokenValue);
10209
+ }
10210
+ }
10211
+ function isClassContentExit(ch) {
10212
+ return ch === 93 /* closeBracket */ || ch === -1 /* EOF */ || pos >= end;
10213
+ }
10214
+ function scanClassRanges() {
10215
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 91 /* openBracket */);
10216
+ if (charCodeChecked(pos) === 94 /* caret */) {
10217
+ pos++;
10195
10218
  }
10196
- function scanClassRanges() {
10197
- Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
10198
- if (text2.charCodeAt(pos) === 94 /* caret */) {
10219
+ while (true) {
10220
+ const ch = charCodeChecked(pos);
10221
+ if (isClassContentExit(ch)) {
10222
+ return;
10223
+ }
10224
+ const minStart = pos;
10225
+ const minCharacter = scanClassAtom();
10226
+ if (charCodeChecked(pos) === 45 /* minus */) {
10199
10227
  pos++;
10228
+ const ch2 = charCodeChecked(pos);
10229
+ if (isClassContentExit(ch2)) {
10230
+ return;
10231
+ }
10232
+ if (!minCharacter && !annexB) {
10233
+ error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
10234
+ }
10235
+ const maxStart = pos;
10236
+ const maxCharacter = scanClassAtom();
10237
+ if (!maxCharacter && !annexB) {
10238
+ error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
10239
+ continue;
10240
+ }
10241
+ if (!minCharacter) {
10242
+ continue;
10243
+ }
10244
+ const minCharacterValue = codePointAt(minCharacter, 0);
10245
+ const maxCharacterValue = codePointAt(maxCharacter, 0);
10246
+ if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
10247
+ error(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
10248
+ }
10200
10249
  }
10201
- while (pos < end2) {
10202
- const ch = text2.charCodeAt(pos);
10203
- if (isClassContentExit(ch)) {
10250
+ }
10251
+ }
10252
+ function scanClassSetExpression() {
10253
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 91 /* openBracket */);
10254
+ let isCharacterComplement = false;
10255
+ if (charCodeChecked(pos) === 94 /* caret */) {
10256
+ pos++;
10257
+ isCharacterComplement = true;
10258
+ }
10259
+ let expressionMayContainStrings = false;
10260
+ let ch = charCodeChecked(pos);
10261
+ if (isClassContentExit(ch)) {
10262
+ return;
10263
+ }
10264
+ let start2 = pos;
10265
+ let operand;
10266
+ switch (text.slice(pos, pos + 2)) {
10267
+ case "--":
10268
+ case "&&":
10269
+ error(Diagnostics.Expected_a_class_set_operand);
10270
+ mayContainStrings = false;
10271
+ break;
10272
+ default:
10273
+ operand = scanClassSetOperand();
10274
+ break;
10275
+ }
10276
+ switch (charCodeChecked(pos)) {
10277
+ case 45 /* minus */:
10278
+ if (charCodeChecked(pos + 1) === 45 /* minus */) {
10279
+ if (isCharacterComplement && mayContainStrings) {
10280
+ error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
10281
+ }
10282
+ expressionMayContainStrings = mayContainStrings;
10283
+ scanClassSetSubExpression(3 /* ClassSubtraction */);
10284
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10204
10285
  return;
10205
10286
  }
10206
- const minStart = pos;
10207
- const minCharacter = scanClassAtom();
10208
- if (text2.charCodeAt(pos) === 45 /* minus */) {
10287
+ break;
10288
+ case 38 /* ampersand */:
10289
+ if (charCodeChecked(pos + 1) === 38 /* ampersand */) {
10290
+ scanClassSetSubExpression(2 /* ClassIntersection */);
10291
+ if (isCharacterComplement && mayContainStrings) {
10292
+ error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
10293
+ }
10294
+ expressionMayContainStrings = mayContainStrings;
10295
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10296
+ return;
10297
+ } else {
10298
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10299
+ }
10300
+ break;
10301
+ default:
10302
+ if (isCharacterComplement && mayContainStrings) {
10303
+ error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
10304
+ }
10305
+ expressionMayContainStrings = mayContainStrings;
10306
+ break;
10307
+ }
10308
+ while (true) {
10309
+ ch = charCodeChecked(pos);
10310
+ if (ch === -1 /* EOF */) {
10311
+ break;
10312
+ }
10313
+ switch (ch) {
10314
+ case 45 /* minus */:
10209
10315
  pos++;
10210
- const ch2 = text2.charCodeAt(pos);
10211
- if (isClassContentExit(ch2)) {
10316
+ ch = charCodeChecked(pos);
10317
+ if (isClassContentExit(ch)) {
10318
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10212
10319
  return;
10213
10320
  }
10214
- if (!minCharacter && !annexB) {
10215
- error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
10216
- }
10217
- const maxStart = pos;
10218
- const maxCharacter = scanClassAtom();
10219
- if (!maxCharacter && !annexB) {
10220
- error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
10221
- continue;
10222
- }
10223
- if (!minCharacter) {
10321
+ if (ch === 45 /* minus */) {
10322
+ pos++;
10323
+ error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10324
+ start2 = pos - 2;
10325
+ operand = text.slice(start2, pos);
10224
10326
  continue;
10327
+ } else {
10328
+ if (!operand) {
10329
+ error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
10330
+ }
10331
+ const secondStart = pos;
10332
+ const secondOperand = scanClassSetOperand();
10333
+ if (isCharacterComplement && mayContainStrings) {
10334
+ error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
10335
+ }
10336
+ expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
10337
+ if (!secondOperand) {
10338
+ error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
10339
+ break;
10340
+ }
10341
+ if (!operand) {
10342
+ break;
10343
+ }
10344
+ const minCharacterValue = codePointAt(operand, 0);
10345
+ const maxCharacterValue = codePointAt(secondOperand, 0);
10346
+ if (operand.length === charSize(minCharacterValue) && secondOperand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
10347
+ error(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
10348
+ }
10225
10349
  }
10226
- const minCharacterValue = codePointAt(minCharacter, 0);
10227
- const maxCharacterValue = codePointAt(maxCharacter, 0);
10228
- if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
10229
- error(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
10350
+ break;
10351
+ case 38 /* ampersand */:
10352
+ start2 = pos;
10353
+ pos++;
10354
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
10355
+ pos++;
10356
+ error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10357
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
10358
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10359
+ pos++;
10360
+ }
10361
+ } else {
10362
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
10230
10363
  }
10231
- }
10232
- }
10233
- }
10234
- function scanClassSetExpression() {
10235
- Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
10236
- let isCharacterComplement = false;
10237
- if (text2.charCodeAt(pos) === 94 /* caret */) {
10238
- pos++;
10239
- isCharacterComplement = true;
10364
+ operand = text.slice(start2, pos);
10365
+ continue;
10240
10366
  }
10241
- let expressionMayContainStrings = false;
10242
- let ch = text2.charCodeAt(pos);
10243
- if (isClassContentExit(ch)) {
10244
- return;
10367
+ if (isClassContentExit(charCodeChecked(pos))) {
10368
+ break;
10245
10369
  }
10246
- let start2 = pos;
10247
- let oprand;
10248
- switch (text2.slice(pos, pos + 2)) {
10370
+ start2 = pos;
10371
+ switch (text.slice(pos, pos + 2)) {
10249
10372
  case "--":
10250
10373
  case "&&":
10251
- error(Diagnostics.Expected_a_class_set_oprand);
10252
- mayContainStrings = false;
10374
+ error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
10375
+ pos += 2;
10376
+ operand = text.slice(start2, pos);
10253
10377
  break;
10254
10378
  default:
10255
- oprand = scanClassSetOprand();
10379
+ operand = scanClassSetOperand();
10256
10380
  break;
10257
10381
  }
10258
- switch (text2.charCodeAt(pos)) {
10382
+ }
10383
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10384
+ }
10385
+ function scanClassSetSubExpression(expressionType) {
10386
+ let expressionMayContainStrings = mayContainStrings;
10387
+ while (true) {
10388
+ let ch = charCodeChecked(pos);
10389
+ if (isClassContentExit(ch)) {
10390
+ break;
10391
+ }
10392
+ switch (ch) {
10259
10393
  case 45 /* minus */:
10260
- if (text2.charCodeAt(pos + 1) === 45 /* minus */) {
10261
- if (isCharacterComplement && mayContainStrings) {
10262
- error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
10394
+ pos++;
10395
+ if (charCodeChecked(pos) === 45 /* minus */) {
10396
+ pos++;
10397
+ if (expressionType !== 3 /* ClassSubtraction */) {
10398
+ error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10263
10399
  }
10264
- expressionMayContainStrings = mayContainStrings;
10265
- scanClassSetSubExpression(3 /* ClassSubtraction */);
10266
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10267
- return;
10400
+ } else {
10401
+ error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
10268
10402
  }
10269
10403
  break;
10270
10404
  case 38 /* ampersand */:
10271
- if (text2.charCodeAt(pos + 1) === 38 /* ampersand */) {
10272
- scanClassSetSubExpression(2 /* ClassIntersection */);
10273
- if (isCharacterComplement && mayContainStrings) {
10274
- error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
10405
+ pos++;
10406
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
10407
+ pos++;
10408
+ if (expressionType !== 2 /* ClassIntersection */) {
10409
+ error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10410
+ }
10411
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
10412
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10413
+ pos++;
10275
10414
  }
10276
- expressionMayContainStrings = mayContainStrings;
10277
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10278
- return;
10279
10415
  } else {
10280
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10416
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
10281
10417
  }
10282
10418
  break;
10283
10419
  default:
10284
- if (isCharacterComplement && mayContainStrings) {
10285
- error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
10420
+ switch (expressionType) {
10421
+ case 3 /* ClassSubtraction */:
10422
+ error(Diagnostics._0_expected, pos, 0, "--");
10423
+ break;
10424
+ case 2 /* ClassIntersection */:
10425
+ error(Diagnostics._0_expected, pos, 0, "&&");
10426
+ break;
10427
+ default:
10428
+ break;
10286
10429
  }
10287
- expressionMayContainStrings = mayContainStrings;
10288
10430
  break;
10289
10431
  }
10290
- while (pos < end2) {
10291
- ch = text2.charCodeAt(pos);
10292
- switch (ch) {
10293
- case 45 /* minus */:
10294
- pos++;
10295
- ch = text2.charCodeAt(pos);
10296
- if (isClassContentExit(ch)) {
10297
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10298
- return;
10299
- }
10300
- if (ch === 45 /* minus */) {
10301
- pos++;
10302
- error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10303
- start2 = pos - 2;
10304
- oprand = text2.slice(start2, pos);
10305
- continue;
10306
- } else {
10307
- if (!oprand) {
10308
- error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
10309
- }
10310
- const secondStart = pos;
10311
- const secondOprand = scanClassSetOprand();
10312
- if (isCharacterComplement && mayContainStrings) {
10313
- error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
10314
- }
10315
- expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
10316
- if (!secondOprand) {
10317
- error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
10318
- break;
10319
- }
10320
- if (!oprand) {
10321
- break;
10322
- }
10323
- const minCharacterValue = codePointAt(oprand, 0);
10324
- const maxCharacterValue = codePointAt(secondOprand, 0);
10325
- if (oprand.length === charSize(minCharacterValue) && secondOprand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
10326
- error(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
10327
- }
10328
- }
10329
- break;
10330
- case 38 /* ampersand */:
10331
- start2 = pos;
10332
- pos++;
10333
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
10334
- pos++;
10335
- error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10336
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
10337
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10338
- pos++;
10339
- }
10340
- } else {
10341
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
10342
- }
10343
- oprand = text2.slice(start2, pos);
10344
- continue;
10345
- }
10346
- if (isClassContentExit(text2.charCodeAt(pos))) {
10347
- break;
10348
- }
10349
- start2 = pos;
10350
- switch (text2.slice(pos, pos + 2)) {
10351
- case "--":
10352
- case "&&":
10353
- error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
10354
- pos += 2;
10355
- oprand = text2.slice(start2, pos);
10356
- break;
10357
- default:
10358
- oprand = scanClassSetOprand();
10359
- break;
10360
- }
10432
+ ch = charCodeChecked(pos);
10433
+ if (isClassContentExit(ch)) {
10434
+ error(Diagnostics.Expected_a_class_set_operand);
10435
+ break;
10361
10436
  }
10362
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
10437
+ scanClassSetOperand();
10438
+ expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
10363
10439
  }
10364
- function scanClassSetSubExpression(expressionType) {
10365
- let expressionMayContainStrings = mayContainStrings;
10366
- while (pos < end2) {
10367
- let ch = text2.charCodeAt(pos);
10368
- if (isClassContentExit(ch)) {
10369
- break;
10370
- }
10371
- switch (ch) {
10372
- case 45 /* minus */:
10373
- pos++;
10374
- if (text2.charCodeAt(pos) === 45 /* minus */) {
10375
- pos++;
10376
- if (expressionType !== 3 /* ClassSubtraction */) {
10377
- error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10378
- }
10379
- } else {
10380
- error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
10381
- }
10382
- break;
10383
- case 38 /* ampersand */:
10440
+ mayContainStrings = expressionMayContainStrings;
10441
+ }
10442
+ function scanClassSetOperand() {
10443
+ mayContainStrings = false;
10444
+ switch (charCodeChecked(pos)) {
10445
+ case -1 /* EOF */:
10446
+ return "";
10447
+ case 91 /* openBracket */:
10448
+ pos++;
10449
+ scanClassSetExpression();
10450
+ scanExpectedChar(93 /* closeBracket */);
10451
+ return "";
10452
+ case 92 /* backslash */:
10453
+ pos++;
10454
+ if (scanCharacterClassEscape()) {
10455
+ return "";
10456
+ } else if (charCodeChecked(pos) === 113 /* q */) {
10457
+ pos++;
10458
+ if (charCodeChecked(pos) === 123 /* openBrace */) {
10384
10459
  pos++;
10385
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
10386
- pos++;
10387
- if (expressionType !== 2 /* ClassIntersection */) {
10388
- error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
10389
- }
10390
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
10391
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10392
- pos++;
10393
- }
10394
- } else {
10395
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
10396
- }
10397
- break;
10398
- default:
10399
- switch (expressionType) {
10400
- case 3 /* ClassSubtraction */:
10401
- error(Diagnostics._0_expected, pos, 0, "--");
10402
- break;
10403
- case 2 /* ClassIntersection */:
10404
- error(Diagnostics._0_expected, pos, 0, "&&");
10405
- break;
10406
- default:
10407
- break;
10408
- }
10409
- break;
10460
+ scanClassStringDisjunctionContents();
10461
+ scanExpectedChar(125 /* closeBrace */);
10462
+ return "";
10463
+ } else {
10464
+ error(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
10465
+ return "q";
10466
+ }
10410
10467
  }
10411
- ch = text2.charCodeAt(pos);
10412
- if (isClassContentExit(ch)) {
10413
- error(Diagnostics.Expected_a_class_set_oprand);
10468
+ pos--;
10469
+ default:
10470
+ return scanClassSetCharacter();
10471
+ }
10472
+ }
10473
+ function scanClassStringDisjunctionContents() {
10474
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 123 /* openBrace */);
10475
+ let characterCount = 0;
10476
+ while (true) {
10477
+ const ch = charCodeChecked(pos);
10478
+ switch (ch) {
10479
+ case -1 /* EOF */:
10480
+ return;
10481
+ case 125 /* closeBrace */:
10482
+ if (characterCount !== 1) {
10483
+ mayContainStrings = true;
10484
+ }
10485
+ return;
10486
+ case 124 /* bar */:
10487
+ if (characterCount !== 1) {
10488
+ mayContainStrings = true;
10489
+ }
10490
+ pos++;
10491
+ start = pos;
10492
+ characterCount = 0;
10493
+ break;
10494
+ default:
10495
+ scanClassSetCharacter();
10496
+ characterCount++;
10414
10497
  break;
10415
- }
10416
- scanClassSetOprand();
10417
- expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
10418
10498
  }
10419
- mayContainStrings = expressionMayContainStrings;
10420
10499
  }
10421
- function scanClassSetOprand() {
10422
- mayContainStrings = false;
10423
- switch (text2.charCodeAt(pos)) {
10424
- case 91 /* openBracket */:
10500
+ }
10501
+ function scanClassSetCharacter() {
10502
+ const ch = charCodeChecked(pos);
10503
+ if (ch === -1 /* EOF */) {
10504
+ return "";
10505
+ }
10506
+ if (ch === 92 /* backslash */) {
10507
+ pos++;
10508
+ const ch2 = charCodeChecked(pos);
10509
+ switch (ch2) {
10510
+ case 98 /* b */:
10425
10511
  pos++;
10426
- scanClassSetExpression();
10427
- scanExpectedChar(93 /* closeBracket */);
10428
- return "";
10429
- case 92 /* backslash */:
10512
+ return "\b";
10513
+ case 38 /* ampersand */:
10514
+ case 45 /* minus */:
10515
+ case 33 /* exclamation */:
10516
+ case 35 /* hash */:
10517
+ case 37 /* percent */:
10518
+ case 44 /* comma */:
10519
+ case 58 /* colon */:
10520
+ case 59 /* semicolon */:
10521
+ case 60 /* lessThan */:
10522
+ case 61 /* equals */:
10523
+ case 62 /* greaterThan */:
10524
+ case 64 /* at */:
10525
+ case 96 /* backtick */:
10526
+ case 126 /* tilde */:
10430
10527
  pos++;
10431
- if (scanCharacterClassEscape()) {
10432
- return "";
10433
- } else if (text2.charCodeAt(pos) === 113 /* q */) {
10434
- pos++;
10435
- if (text2.charCodeAt(pos) === 123 /* openBrace */) {
10436
- pos++;
10437
- scanClassStringDisjunctionContents();
10438
- scanExpectedChar(125 /* closeBrace */);
10439
- return "";
10440
- } else {
10441
- error(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
10442
- return "q";
10443
- }
10444
- }
10445
- pos--;
10528
+ return String.fromCharCode(ch2);
10446
10529
  default:
10447
- return scanClassSetCharacter();
10448
- }
10449
- }
10450
- function scanClassStringDisjunctionContents() {
10451
- Debug.assertEqual(text2.charCodeAt(pos - 1), 123 /* openBrace */);
10452
- let characterCount = 0;
10453
- while (pos < end2) {
10454
- const ch = text2.charCodeAt(pos);
10455
- switch (ch) {
10456
- case 125 /* closeBrace */:
10457
- if (characterCount !== 1) {
10458
- mayContainStrings = true;
10459
- }
10460
- return;
10461
- case 124 /* bar */:
10462
- if (characterCount !== 1) {
10463
- mayContainStrings = true;
10464
- }
10465
- pos++;
10466
- start = pos;
10467
- characterCount = 0;
10468
- break;
10469
- default:
10470
- scanClassSetCharacter();
10471
- characterCount++;
10472
- break;
10473
- }
10530
+ return scanCharacterEscape(
10531
+ /*atomEscape*/
10532
+ false
10533
+ );
10534
+ }
10535
+ } else if (ch === charCodeChecked(pos + 1)) {
10536
+ switch (ch) {
10537
+ case 38 /* ampersand */:
10538
+ case 33 /* exclamation */:
10539
+ case 35 /* hash */:
10540
+ case 37 /* percent */:
10541
+ case 42 /* asterisk */:
10542
+ case 43 /* plus */:
10543
+ case 44 /* comma */:
10544
+ case 46 /* dot */:
10545
+ case 58 /* colon */:
10546
+ case 59 /* semicolon */:
10547
+ case 60 /* lessThan */:
10548
+ case 61 /* equals */:
10549
+ case 62 /* greaterThan */:
10550
+ case 63 /* question */:
10551
+ case 64 /* at */:
10552
+ case 96 /* backtick */:
10553
+ case 126 /* tilde */:
10554
+ error(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
10555
+ pos += 2;
10556
+ return text.substring(pos - 2, pos);
10474
10557
  }
10475
10558
  }
10476
- function scanClassSetCharacter() {
10477
- const ch = text2.charCodeAt(pos);
10478
- if (ch === 92 /* backslash */) {
10559
+ switch (ch) {
10560
+ case 47 /* slash */:
10561
+ case 40 /* openParen */:
10562
+ case 41 /* closeParen */:
10563
+ case 91 /* openBracket */:
10564
+ case 93 /* closeBracket */:
10565
+ case 123 /* openBrace */:
10566
+ case 125 /* closeBrace */:
10567
+ case 45 /* minus */:
10568
+ case 124 /* bar */:
10569
+ error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10479
10570
  pos++;
10480
- const ch2 = text2.charCodeAt(pos);
10481
- switch (ch2) {
10482
- case 98 /* b */:
10483
- pos++;
10484
- return "\b";
10485
- case 38 /* ampersand */:
10486
- case 45 /* minus */:
10487
- case 33 /* exclamation */:
10488
- case 35 /* hash */:
10489
- case 37 /* percent */:
10490
- case 44 /* comma */:
10491
- case 58 /* colon */:
10492
- case 59 /* semicolon */:
10493
- case 60 /* lessThan */:
10494
- case 61 /* equals */:
10495
- case 62 /* greaterThan */:
10496
- case 64 /* at */:
10497
- case 96 /* backtick */:
10498
- case 126 /* tilde */:
10499
- pos++;
10500
- return String.fromCharCode(ch2);
10501
- default:
10502
- return scanCharacterEscape(
10503
- /*atomEscape*/
10504
- false
10505
- );
10506
- }
10507
- } else if (ch === text2.charCodeAt(pos + 1)) {
10508
- switch (ch) {
10509
- case 38 /* ampersand */:
10510
- case 33 /* exclamation */:
10511
- case 35 /* hash */:
10512
- case 37 /* percent */:
10513
- case 42 /* asterisk */:
10514
- case 43 /* plus */:
10515
- case 44 /* comma */:
10516
- case 46 /* dot */:
10517
- case 58 /* colon */:
10518
- case 59 /* semicolon */:
10519
- case 60 /* lessThan */:
10520
- case 61 /* equals */:
10521
- case 62 /* greaterThan */:
10522
- case 63 /* question */:
10523
- case 64 /* at */:
10524
- case 96 /* backtick */:
10525
- case 126 /* tilde */:
10526
- error(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
10527
- pos += 2;
10528
- return text2.substring(pos - 2, pos);
10529
- }
10530
- }
10571
+ return String.fromCharCode(ch);
10572
+ }
10573
+ return scanSourceCharacter();
10574
+ }
10575
+ function scanClassAtom() {
10576
+ if (charCodeChecked(pos) === 92 /* backslash */) {
10577
+ pos++;
10578
+ const ch = charCodeChecked(pos);
10531
10579
  switch (ch) {
10532
- case 47 /* slash */:
10533
- case 40 /* openParen */:
10534
- case 41 /* closeParen */:
10535
- case 91 /* openBracket */:
10536
- case 93 /* closeBracket */:
10537
- case 123 /* openBrace */:
10538
- case 125 /* closeBrace */:
10580
+ case 98 /* b */:
10581
+ pos++;
10582
+ return "\b";
10539
10583
  case 45 /* minus */:
10540
- case 124 /* bar */:
10541
- error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
10542
10584
  pos++;
10543
10585
  return String.fromCharCode(ch);
10586
+ default:
10587
+ if (scanCharacterClassEscape()) {
10588
+ return "";
10589
+ }
10590
+ return scanCharacterEscape(
10591
+ /*atomEscape*/
10592
+ false
10593
+ );
10544
10594
  }
10595
+ } else {
10545
10596
  return scanSourceCharacter();
10546
10597
  }
10547
- function scanClassAtom() {
10548
- if (text2.charCodeAt(pos) === 92 /* backslash */) {
10598
+ }
10599
+ function scanCharacterClassEscape() {
10600
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
10601
+ let isCharacterComplement = false;
10602
+ const start2 = pos - 1;
10603
+ const ch = charCodeChecked(pos);
10604
+ switch (ch) {
10605
+ case 100 /* d */:
10606
+ case 68 /* D */:
10607
+ case 115 /* s */:
10608
+ case 83 /* S */:
10609
+ case 119 /* w */:
10610
+ case 87 /* W */:
10549
10611
  pos++;
10550
- const ch = text2.charCodeAt(pos);
10551
- switch (ch) {
10552
- case 98 /* b */:
10553
- pos++;
10554
- return "\b";
10555
- case 45 /* minus */:
10556
- pos++;
10557
- return String.fromCharCode(ch);
10558
- default:
10559
- if (scanCharacterClassEscape()) {
10560
- return "";
10561
- }
10562
- return scanCharacterEscape(
10563
- /*atomEscape*/
10564
- false
10565
- );
10566
- }
10567
- } else {
10568
- return scanSourceCharacter();
10569
- }
10570
- }
10571
- function scanCharacterClassEscape() {
10572
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
10573
- let isCharacterComplement = false;
10574
- const start2 = pos - 1;
10575
- const ch = text2.charCodeAt(pos);
10576
- switch (ch) {
10577
- case 100 /* d */:
10578
- case 68 /* D */:
10579
- case 115 /* s */:
10580
- case 83 /* S */:
10581
- case 119 /* w */:
10582
- case 87 /* W */:
10583
- pos++;
10584
- return true;
10585
- case 80 /* P */:
10586
- isCharacterComplement = true;
10587
- case 112 /* p */:
10612
+ return true;
10613
+ case 80 /* P */:
10614
+ isCharacterComplement = true;
10615
+ case 112 /* p */:
10616
+ pos++;
10617
+ if (charCodeChecked(pos) === 123 /* openBrace */) {
10588
10618
  pos++;
10589
- if (text2.charCodeAt(pos) === 123 /* openBrace */) {
10619
+ const propertyNameOrValueStart = pos;
10620
+ const propertyNameOrValue = scanWordCharacters();
10621
+ if (charCodeChecked(pos) === 61 /* equals */) {
10622
+ const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
10623
+ if (pos === propertyNameOrValueStart) {
10624
+ error(Diagnostics.Expected_a_Unicode_property_name);
10625
+ } else if (propertyName === void 0) {
10626
+ error(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10627
+ const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
10628
+ if (suggestion) {
10629
+ error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
10630
+ }
10631
+ }
10590
10632
  pos++;
10591
- const propertyNameOrValueStart = pos;
10592
- const propertyNameOrValue = scanWordCharacters();
10593
- if (text2.charCodeAt(pos) === 61 /* equals */) {
10594
- const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
10595
- if (pos === propertyNameOrValueStart) {
10596
- error(Diagnostics.Expected_a_Unicode_property_name);
10597
- } else if (propertyName === void 0) {
10598
- error(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10599
- const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
10600
- if (suggestion) {
10601
- error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
10602
- }
10633
+ const propertyValueStart = pos;
10634
+ const propertyValue = scanWordCharacters();
10635
+ if (pos === propertyValueStart) {
10636
+ error(Diagnostics.Expected_a_Unicode_property_value);
10637
+ } else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
10638
+ error(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
10639
+ const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
10640
+ if (suggestion) {
10641
+ error(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
10603
10642
  }
10604
- pos++;
10605
- const propertyValueStart = pos;
10606
- const propertyValue = scanWordCharacters();
10607
- if (pos === propertyValueStart) {
10608
- error(Diagnostics.Expected_a_Unicode_property_value);
10609
- } else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
10610
- error(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
10611
- const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
10612
- if (suggestion) {
10613
- error(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
10614
- }
10643
+ }
10644
+ } else {
10645
+ if (pos === propertyNameOrValueStart) {
10646
+ error(Diagnostics.Expected_a_Unicode_property_name_or_value);
10647
+ } else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
10648
+ if (!unicodeSetsMode) {
10649
+ error(Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10650
+ } else if (isCharacterComplement) {
10651
+ error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10652
+ } else {
10653
+ mayContainStrings = true;
10615
10654
  }
10616
- } else {
10617
- if (pos === propertyNameOrValueStart) {
10618
- error(Diagnostics.Expected_a_Unicode_property_name_or_value);
10619
- } else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
10620
- if (!unicodeSetsMode) {
10621
- error(Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10622
- } else if (isCharacterComplement) {
10623
- error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10624
- } else {
10625
- mayContainStrings = true;
10626
- }
10627
- } else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
10628
- error(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10629
- const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
10630
- if (suggestion) {
10631
- error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
10632
- }
10655
+ } else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
10656
+ error(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
10657
+ const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
10658
+ if (suggestion) {
10659
+ error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
10633
10660
  }
10634
10661
  }
10635
- scanExpectedChar(125 /* closeBrace */);
10636
- if (!unicodeMode) {
10637
- 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);
10638
- }
10639
- } else if (unicodeMode) {
10640
- error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
10641
10662
  }
10642
- return true;
10643
- }
10644
- return false;
10645
- }
10646
- function scanWordCharacters() {
10647
- let value = "";
10648
- while (pos < end2) {
10649
- const ch = text2.charCodeAt(pos);
10650
- if (!isWordCharacter(ch)) {
10651
- break;
10663
+ scanExpectedChar(125 /* closeBrace */);
10664
+ if (!unicodeMode) {
10665
+ 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);
10666
+ }
10667
+ } else if (unicodeMode) {
10668
+ error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
10652
10669
  }
10653
- value += String.fromCharCode(ch);
10654
- pos++;
10670
+ return true;
10671
+ }
10672
+ return false;
10673
+ }
10674
+ function scanWordCharacters() {
10675
+ let value = "";
10676
+ while (true) {
10677
+ const ch = charCodeChecked(pos);
10678
+ if (ch === -1 /* EOF */ || !isWordCharacter(ch)) {
10679
+ break;
10655
10680
  }
10656
- return value;
10681
+ value += String.fromCharCode(ch);
10682
+ pos++;
10657
10683
  }
10658
- function scanSourceCharacter() {
10659
- const size = unicodeMode ? charSize(codePointAt(text2, pos)) : 1;
10660
- pos += size;
10661
- return text2.substring(pos - size, pos);
10684
+ return value;
10685
+ }
10686
+ function scanSourceCharacter() {
10687
+ const size = unicodeMode ? charSize(charCodeChecked(pos)) : 1;
10688
+ pos += size;
10689
+ return size > 0 ? text.substring(pos - size, pos) : "";
10690
+ }
10691
+ function scanExpectedChar(ch) {
10692
+ if (charCodeChecked(pos) === ch) {
10693
+ pos++;
10694
+ } else {
10695
+ error(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
10662
10696
  }
10663
- function scanExpectedChar(ch) {
10664
- if (text2.charCodeAt(pos) === ch) {
10665
- pos++;
10666
- } else {
10667
- error(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
10668
- }
10697
+ }
10698
+ scanDisjunction(
10699
+ /*isInGroup*/
10700
+ false
10701
+ );
10702
+ forEach(groupNameReferences, (reference) => {
10703
+ if (!(groupSpecifiers == null ? void 0 : groupSpecifiers.has(reference.name))) {
10704
+ error(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
10669
10705
  }
10670
- scanDisjunction(
10671
- /*isInGroup*/
10672
- false
10673
- );
10674
- forEach(groupNameReferences, (reference) => {
10675
- if (!groupSpecifiers.has(reference.name)) {
10676
- error(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
10677
- }
10678
- });
10679
- forEach(decimalEscapes, (escape) => {
10680
- if (!annexB && escape.value > numberOfCapturingGroups) {
10681
- if (numberOfCapturingGroups) {
10682
- 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);
10683
- } else {
10684
- error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
10685
- }
10706
+ });
10707
+ forEach(decimalEscapes, (escape) => {
10708
+ if (!annexB && escape.value > numberOfCapturingGroups) {
10709
+ if (numberOfCapturingGroups) {
10710
+ 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);
10711
+ } else {
10712
+ error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
10686
10713
  }
10687
- });
10688
- }
10689
- function checkRegularExpressionFlagAvailable(flag, pos2) {
10690
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
10691
- if (availableFrom && languageVersion < availableFrom) {
10692
- error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
10693
10714
  }
10715
+ });
10716
+ }
10717
+ function checkRegularExpressionFlagAvailable(flag, pos2) {
10718
+ const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
10719
+ if (availableFrom && languageVersion < availableFrom) {
10720
+ error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
10694
10721
  }
10695
10722
  }
10696
10723
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
@@ -10758,9 +10785,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10758
10785
  if (pos >= end) {
10759
10786
  return token = 1 /* EndOfFileToken */;
10760
10787
  }
10761
- let char = text.charCodeAt(pos);
10788
+ let char = charCodeUnchecked(pos);
10762
10789
  if (char === 60 /* lessThan */) {
10763
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
10790
+ if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
10764
10791
  pos += 2;
10765
10792
  return token = 31 /* LessThanSlashToken */;
10766
10793
  }
@@ -10773,7 +10800,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10773
10800
  }
10774
10801
  let firstNonWhitespace = 0;
10775
10802
  while (pos < end) {
10776
- char = text.charCodeAt(pos);
10803
+ char = charCodeUnchecked(pos);
10777
10804
  if (char === 123 /* openBrace */) {
10778
10805
  break;
10779
10806
  }
@@ -10805,7 +10832,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10805
10832
  function scanJsxIdentifier() {
10806
10833
  if (tokenIsIdentifierOrKeyword(token)) {
10807
10834
  while (pos < end) {
10808
- const ch = text.charCodeAt(pos);
10835
+ const ch = charCodeUnchecked(pos);
10809
10836
  if (ch === 45 /* minus */) {
10810
10837
  tokenValue += "-";
10811
10838
  pos++;
@@ -10823,7 +10850,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10823
10850
  }
10824
10851
  function scanJsxAttributeValue() {
10825
10852
  fullStartPos = pos;
10826
- switch (text.charCodeAt(pos)) {
10853
+ switch (charCodeUnchecked(pos)) {
10827
10854
  case 34 /* doubleQuote */:
10828
10855
  case 39 /* singleQuote */:
10829
10856
  tokenValue = scanString(
@@ -10845,11 +10872,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10845
10872
  if (pos >= end) {
10846
10873
  return token = 1 /* EndOfFileToken */;
10847
10874
  }
10848
- for (let ch = text.charCodeAt(pos); pos < end && (!isLineBreak(ch) && ch !== 96 /* backtick */); ch = codePointAt(text, ++pos)) {
10875
+ for (let ch = charCodeUnchecked(pos); pos < end && (!isLineBreak(ch) && ch !== 96 /* backtick */); ch = codePointUnchecked(++pos)) {
10849
10876
  if (!inBackticks) {
10850
10877
  if (ch === 123 /* openBrace */) {
10851
10878
  break;
10852
- } else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(text.charCodeAt(pos - 1)) && !(pos + 1 < end && isWhiteSpaceLike(text.charCodeAt(pos + 1)))) {
10879
+ } else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(charCodeUnchecked(pos - 1)) && !(pos + 1 < end && isWhiteSpaceLike(charCodeUnchecked(pos + 1)))) {
10853
10880
  break;
10854
10881
  }
10855
10882
  }
@@ -10866,21 +10893,21 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10866
10893
  if (pos >= end) {
10867
10894
  return token = 1 /* EndOfFileToken */;
10868
10895
  }
10869
- const ch = codePointAt(text, pos);
10896
+ const ch = codePointUnchecked(pos);
10870
10897
  pos += charSize(ch);
10871
10898
  switch (ch) {
10872
10899
  case 9 /* tab */:
10873
10900
  case 11 /* verticalTab */:
10874
10901
  case 12 /* formFeed */:
10875
10902
  case 32 /* space */:
10876
- while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
10903
+ while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
10877
10904
  pos++;
10878
10905
  }
10879
10906
  return token = 5 /* WhitespaceTrivia */;
10880
10907
  case 64 /* at */:
10881
10908
  return token = 60 /* AtToken */;
10882
10909
  case 13 /* carriageReturn */:
10883
- if (text.charCodeAt(pos) === 10 /* lineFeed */) {
10910
+ if (charCodeUnchecked(pos) === 10 /* lineFeed */) {
10884
10911
  pos++;
10885
10912
  }
10886
10913
  case 10 /* lineFeed */:
@@ -10936,7 +10963,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10936
10963
  }
10937
10964
  if (isIdentifierStart(ch, languageVersion)) {
10938
10965
  let char = ch;
10939
- while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */)
10966
+ while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === 45 /* minus */)
10940
10967
  pos += charSize(char);
10941
10968
  tokenValue = text.substring(tokenStart, pos);
10942
10969
  if (char === 92 /* backslash */) {
@@ -11046,6 +11073,9 @@ function charSize(ch) {
11046
11073
  if (ch >= 65536) {
11047
11074
  return 2;
11048
11075
  }
11076
+ if (ch === -1 /* EOF */) {
11077
+ return 0;
11078
+ }
11049
11079
  return 1;
11050
11080
  }
11051
11081
  function utf16EncodeAsStringFallback(codePoint) {
@@ -13536,7 +13566,8 @@ function createFileDiagnosticFromMessageChain(file, start, length2, messageChain
13536
13566
  code: messageChain.code,
13537
13567
  category: messageChain.category,
13538
13568
  messageText: messageChain.next ? messageChain : messageChain.messageText,
13539
- relatedInformation
13569
+ relatedInformation,
13570
+ canonicalHead: messageChain.canonicalHead
13540
13571
  };
13541
13572
  }
13542
13573
  function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) {
@@ -13568,6 +13599,12 @@ function createDiagnosticForRange(sourceFile, range, message) {
13568
13599
  messageText: message.message
13569
13600
  };
13570
13601
  }
13602
+ function getCanonicalDiagnostic(message, ...args) {
13603
+ return {
13604
+ code: message.code,
13605
+ messageText: formatMessage(message, ...args)
13606
+ };
13607
+ }
13571
13608
  function getSpanOfTokenAtPosition(sourceFile, pos) {
13572
13609
  const scanner = createScanner(
13573
13610
  sourceFile.languageVersion,
@@ -17380,7 +17417,9 @@ function compareDiagnostics(d1, d2) {
17380
17417
  return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */;
17381
17418
  }
17382
17419
  function compareDiagnosticsSkipRelatedInformation(d1, d2) {
17383
- return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */;
17420
+ const code1 = getDiagnosticCode(d1);
17421
+ const code2 = getDiagnosticCode(d2);
17422
+ return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || compareValues(code1, code2) || compareMessageText(d1, d2) || 0 /* EqualTo */;
17384
17423
  }
17385
17424
  function compareRelatedInformation(d1, d2) {
17386
17425
  if (!d1.relatedInformation && !d2.relatedInformation) {
@@ -17394,21 +17433,32 @@ function compareRelatedInformation(d1, d2) {
17394
17433
  }
17395
17434
  return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */;
17396
17435
  }
17397
- function compareMessageText(t1, t2) {
17398
- if (typeof t1 === "string" && typeof t2 === "string") {
17399
- return compareStringsCaseSensitive(t1, t2);
17436
+ function compareMessageText(d1, d2) {
17437
+ let headMsg1 = getDiagnosticMessage(d1);
17438
+ let headMsg2 = getDiagnosticMessage(d2);
17439
+ if (typeof headMsg1 !== "string") {
17440
+ headMsg1 = headMsg1.messageText;
17400
17441
  }
17401
- if (typeof t1 === "string") {
17402
- t1 = { messageText: t1 };
17442
+ if (typeof headMsg2 !== "string") {
17443
+ headMsg2 = headMsg2.messageText;
17403
17444
  }
17404
- if (typeof t2 === "string") {
17405
- t2 = { messageText: t2 };
17445
+ const chain1 = typeof d1.messageText !== "string" ? d1.messageText.next : void 0;
17446
+ const chain2 = typeof d2.messageText !== "string" ? d2.messageText.next : void 0;
17447
+ let res = compareStringsCaseSensitive(headMsg1, headMsg2);
17448
+ if (res) {
17449
+ return res;
17406
17450
  }
17407
- const res = compareStringsCaseSensitive(t1.messageText, t2.messageText);
17451
+ res = compareMessageChain(chain1, chain2);
17408
17452
  if (res) {
17409
17453
  return res;
17410
17454
  }
17411
- return compareMessageChain(t1.next, t2.next);
17455
+ if (d1.canonicalHead && !d2.canonicalHead) {
17456
+ return -1 /* LessThan */;
17457
+ }
17458
+ if (d2.canonicalHead && !d1.canonicalHead) {
17459
+ return 1 /* GreaterThan */;
17460
+ }
17461
+ return 0 /* EqualTo */;
17412
17462
  }
17413
17463
  function compareMessageChain(c1, c2) {
17414
17464
  if (c1 === void 0 && c2 === void 0) {
@@ -17462,7 +17512,19 @@ function compareMessageChainContent(c1, c2) {
17462
17512
  return 0 /* EqualTo */;
17463
17513
  }
17464
17514
  function diagnosticsEqualityComparer(d1, d2) {
17465
- return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) === 0 /* EqualTo */ && compareValues(d1.start, d2.start) === 0 /* EqualTo */ && compareValues(d1.length, d2.length) === 0 /* EqualTo */ && compareValues(d1.code, d2.code) === 0 /* EqualTo */ && messageTextEqualityComparer(d1.messageText, d2.messageText);
17515
+ const code1 = getDiagnosticCode(d1);
17516
+ const code2 = getDiagnosticCode(d2);
17517
+ const msg1 = getDiagnosticMessage(d1);
17518
+ const msg2 = getDiagnosticMessage(d2);
17519
+ return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) === 0 /* EqualTo */ && compareValues(d1.start, d2.start) === 0 /* EqualTo */ && compareValues(d1.length, d2.length) === 0 /* EqualTo */ && compareValues(code1, code2) === 0 /* EqualTo */ && messageTextEqualityComparer(msg1, msg2);
17520
+ }
17521
+ function getDiagnosticCode(d) {
17522
+ var _a;
17523
+ return ((_a = d.canonicalHead) == null ? void 0 : _a.code) || d.code;
17524
+ }
17525
+ function getDiagnosticMessage(d) {
17526
+ var _a;
17527
+ return ((_a = d.canonicalHead) == null ? void 0 : _a.messageText) || d.messageText;
17466
17528
  }
17467
17529
  function messageTextEqualityComparer(m1, m2) {
17468
17530
  const t1 = typeof m1 === "string" ? m1 : m1.messageText;
@@ -46996,6 +47058,7 @@ function createTypeChecker(host) {
46996
47058
  );
46997
47059
  const message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && nodeIsSynthesized(nameArg) ? Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? Diagnostics.Could_not_find_name_0_Did_you_mean_1 : Diagnostics.Cannot_find_name_0_Did_you_mean_1;
46998
47060
  const diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
47061
+ diagnostic.canonicalHead = getCanonicalDiagnostic(nameNotFoundMessage, diagnosticName(nameArg));
46999
47062
  addErrorOrSuggestion(!isUncheckedJS, diagnostic);
47000
47063
  if (suggestion.valueDeclaration) {
47001
47064
  addRelatedInfo(
@@ -54774,7 +54837,7 @@ function createTypeChecker(host) {
54774
54837
  }
54775
54838
  type = anyType;
54776
54839
  }
54777
- links.type = type;
54840
+ links.type ?? (links.type = type);
54778
54841
  }
54779
54842
  return links.type;
54780
54843
  }
@@ -54792,7 +54855,7 @@ function createTypeChecker(host) {
54792
54855
  }
54793
54856
  writeType = anyType;
54794
54857
  }
54795
- links.writeType = writeType || getTypeOfAccessors(symbol);
54858
+ links.writeType ?? (links.writeType = writeType || getTypeOfAccessors(symbol));
54796
54859
  }
54797
54860
  return links.writeType;
54798
54861
  }
@@ -54869,10 +54932,10 @@ function createTypeChecker(host) {
54869
54932
  true
54870
54933
  );
54871
54934
  const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0);
54872
- links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType;
54935
+ links.type ?? (links.type = (exportSymbol == null ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType : getSymbolFlags(targetSymbol) & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType);
54873
54936
  if (!popTypeResolution()) {
54874
54937
  reportCircularityError(exportSymbol ?? symbol);
54875
- return links.type = errorType;
54938
+ return links.type ?? (links.type = errorType);
54876
54939
  }
54877
54940
  }
54878
54941
  return links.type;
@@ -55138,7 +55201,7 @@ function createTypeChecker(host) {
55138
55201
  }
55139
55202
  if (!popTypeResolution()) {
55140
55203
  error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
55141
- return type.resolvedBaseConstructorType = errorType;
55204
+ return type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = errorType);
55142
55205
  }
55143
55206
  if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
55144
55207
  const err = error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
@@ -55155,9 +55218,9 @@ function createTypeChecker(host) {
55155
55218
  addRelatedInfo(err, createDiagnosticForNode(baseConstructorType.symbol.declarations[0], Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn)));
55156
55219
  }
55157
55220
  }
55158
- return type.resolvedBaseConstructorType = errorType;
55221
+ return type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = errorType);
55159
55222
  }
55160
- type.resolvedBaseConstructorType = baseConstructorType;
55223
+ type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = baseConstructorType);
55161
55224
  }
55162
55225
  return type.resolvedBaseConstructorType;
55163
55226
  }
@@ -55398,7 +55461,7 @@ function createTypeChecker(host) {
55398
55461
  error(isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
55399
55462
  }
55400
55463
  }
55401
- links.declaredType = type;
55464
+ links.declaredType ?? (links.declaredType = type);
55402
55465
  }
55403
55466
  return links.declaredType;
55404
55467
  }
@@ -56516,6 +56579,7 @@ function createTypeChecker(host) {
56516
56579
  }
56517
56580
  }
56518
56581
  function getTypeOfMappedSymbol(symbol) {
56582
+ var _a;
56519
56583
  if (!symbol.links.type) {
56520
56584
  const mappedType = symbol.links.mappedType;
56521
56585
  if (!pushTypeResolution(symbol, 0 /* Type */)) {
@@ -56534,7 +56598,7 @@ function createTypeChecker(host) {
56534
56598
  error(currentNode, Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
56535
56599
  type = errorType;
56536
56600
  }
56537
- symbol.links.type = type;
56601
+ (_a = symbol.links).type ?? (_a.type = type);
56538
56602
  }
56539
56603
  return symbol.links.type;
56540
56604
  }
@@ -56887,7 +56951,7 @@ function createTypeChecker(host) {
56887
56951
  }
56888
56952
  result = circularConstraintType;
56889
56953
  }
56890
- t.immediateBaseConstraint = result || noConstraintType;
56954
+ t.immediateBaseConstraint ?? (t.immediateBaseConstraint = result || noConstraintType);
56891
56955
  }
56892
56956
  return t.immediateBaseConstraint;
56893
56957
  }
@@ -57761,7 +57825,7 @@ function createTypeChecker(host) {
57761
57825
  }
57762
57826
  type = anyType;
57763
57827
  }
57764
- signature.resolvedReturnType = type;
57828
+ signature.resolvedReturnType ?? (signature.resolvedReturnType = type);
57765
57829
  }
57766
57830
  return signature.resolvedReturnType;
57767
57831
  }
@@ -58107,9 +58171,9 @@ function createTypeChecker(host) {
58107
58171
  const node = type.node;
58108
58172
  const typeArguments = !node ? emptyArray : node.kind === 183 /* TypeReference */ ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : node.kind === 188 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : map(node.elements, getTypeFromTypeNode);
58109
58173
  if (popTypeResolution()) {
58110
- type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
58174
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments);
58111
58175
  } else {
58112
- type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray;
58176
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray);
58113
58177
  error(
58114
58178
  type.node || currentNode,
58115
58179
  type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
@@ -63168,6 +63232,16 @@ function createTypeChecker(host) {
63168
63232
  errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63169
63233
  }
63170
63234
  if (!headMessage2 && maybeSuppress) {
63235
+ const savedErrorState = captureErrorCalculationState();
63236
+ reportRelationError(headMessage2, source2, target2);
63237
+ let canonical;
63238
+ if (errorInfo && errorInfo !== savedErrorState.errorInfo) {
63239
+ canonical = { code: errorInfo.code, messageText: errorInfo.messageText };
63240
+ }
63241
+ resetErrorInfo(savedErrorState);
63242
+ if (canonical && errorInfo) {
63243
+ errorInfo.canonicalHead = canonical;
63244
+ }
63171
63245
  lastSkippedInfo = [source2, target2];
63172
63246
  return;
63173
63247
  }
@@ -65156,6 +65230,7 @@ function createTypeChecker(host) {
65156
65230
  if (!links.variances) {
65157
65231
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
65158
65232
  const oldVarianceComputation = inVarianceComputation;
65233
+ const saveResolutionStart = resolutionStart;
65159
65234
  if (!inVarianceComputation) {
65160
65235
  inVarianceComputation = true;
65161
65236
  resolutionStart = resolutionTargets.length;
@@ -65190,7 +65265,7 @@ function createTypeChecker(host) {
65190
65265
  }
65191
65266
  if (!oldVarianceComputation) {
65192
65267
  inVarianceComputation = false;
65193
- resolutionStart = 0;
65268
+ resolutionStart = saveResolutionStart;
65194
65269
  }
65195
65270
  links.variances = variances;
65196
65271
  (_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
@@ -69383,7 +69458,7 @@ function createTypeChecker(host) {
69383
69458
  reportCircularityError(declaration.symbol);
69384
69459
  return true;
69385
69460
  }
69386
- links.parameterInitializerContainsUndefined = containsUndefined;
69461
+ links.parameterInitializerContainsUndefined ?? (links.parameterInitializerContainsUndefined = containsUndefined);
69387
69462
  }
69388
69463
  return links.parameterInitializerContainsUndefined;
69389
69464
  }
@@ -71190,7 +71265,7 @@ function createTypeChecker(host) {
71190
71265
  }
71191
71266
  function checkGrammarRegularExpressionLiteral(node) {
71192
71267
  const sourceFile = getSourceFileOfNode(node);
71193
- if (!hasParseDiagnostics(sourceFile)) {
71268
+ if (!hasParseDiagnostics(sourceFile) && !node.isUnterminated) {
71194
71269
  let lastError;
71195
71270
  scanner ?? (scanner = createScanner(
71196
71271
  99 /* ESNext */,
@@ -74792,8 +74867,13 @@ function createTypeChecker(host) {
74792
74867
  if (cached && cached !== resolvingSignature && !candidatesOutArray) {
74793
74868
  return cached;
74794
74869
  }
74870
+ const saveResolutionStart = resolutionStart;
74871
+ if (!cached) {
74872
+ resolutionStart = resolutionTargets.length;
74873
+ }
74795
74874
  links.resolvedSignature = resolvingSignature;
74796
74875
  let result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
74876
+ resolutionStart = saveResolutionStart;
74797
74877
  if (result !== resolvingSignature) {
74798
74878
  if (links.resolvedSignature !== resolvingSignature) {
74799
74879
  result = links.resolvedSignature;