typescript 5.5.0-dev.20240429 → 5.5.0-dev.20240501

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 +1000 -906
  2. package/lib/typescript.js +2121 -1120
  3. package/package.json +2 -2
package/lib/typescript.js CHANGED
@@ -685,6 +685,7 @@ __export(typescript_exports, {
685
685
  getBuildOrderFromAnyBuildOrder: () => getBuildOrderFromAnyBuildOrder,
686
686
  getBuilderCreationParameters: () => getBuilderCreationParameters,
687
687
  getBuilderFileEmit: () => getBuilderFileEmit,
688
+ getCanonicalDiagnostic: () => getCanonicalDiagnostic,
688
689
  getCheckFlags: () => getCheckFlags,
689
690
  getClassExtendsHeritageElement: () => getClassExtendsHeritageElement,
690
691
  getClassLikeDeclarationOfSymbol: () => getClassLikeDeclarationOfSymbol,
@@ -2361,7 +2362,7 @@ module.exports = __toCommonJS(typescript_exports);
2361
2362
 
2362
2363
  // src/compiler/corePublic.ts
2363
2364
  var versionMajorMinor = "5.5";
2364
- var version = `${versionMajorMinor}.0-dev.20240429`;
2365
+ var version = `${versionMajorMinor}.0-dev.20240501`;
2365
2366
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2366
2367
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2367
2368
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6995,22 +6996,22 @@ var ScriptKind = /* @__PURE__ */ ((ScriptKind7) => {
6995
6996
  ScriptKind7[ScriptKind7["Deferred"] = 7] = "Deferred";
6996
6997
  return ScriptKind7;
6997
6998
  })(ScriptKind || {});
6998
- var ScriptTarget = /* @__PURE__ */ ((ScriptTarget11) => {
6999
- ScriptTarget11[ScriptTarget11["ES3"] = 0] = "ES3";
7000
- ScriptTarget11[ScriptTarget11["ES5"] = 1] = "ES5";
7001
- ScriptTarget11[ScriptTarget11["ES2015"] = 2] = "ES2015";
7002
- ScriptTarget11[ScriptTarget11["ES2016"] = 3] = "ES2016";
7003
- ScriptTarget11[ScriptTarget11["ES2017"] = 4] = "ES2017";
7004
- ScriptTarget11[ScriptTarget11["ES2018"] = 5] = "ES2018";
7005
- ScriptTarget11[ScriptTarget11["ES2019"] = 6] = "ES2019";
7006
- ScriptTarget11[ScriptTarget11["ES2020"] = 7] = "ES2020";
7007
- ScriptTarget11[ScriptTarget11["ES2021"] = 8] = "ES2021";
7008
- ScriptTarget11[ScriptTarget11["ES2022"] = 9] = "ES2022";
7009
- ScriptTarget11[ScriptTarget11["ES2023"] = 10] = "ES2023";
7010
- ScriptTarget11[ScriptTarget11["ESNext"] = 99] = "ESNext";
7011
- ScriptTarget11[ScriptTarget11["JSON"] = 100] = "JSON";
7012
- ScriptTarget11[ScriptTarget11["Latest"] = 99 /* ESNext */] = "Latest";
7013
- return ScriptTarget11;
6999
+ var ScriptTarget = /* @__PURE__ */ ((ScriptTarget12) => {
7000
+ ScriptTarget12[ScriptTarget12["ES3"] = 0] = "ES3";
7001
+ ScriptTarget12[ScriptTarget12["ES5"] = 1] = "ES5";
7002
+ ScriptTarget12[ScriptTarget12["ES2015"] = 2] = "ES2015";
7003
+ ScriptTarget12[ScriptTarget12["ES2016"] = 3] = "ES2016";
7004
+ ScriptTarget12[ScriptTarget12["ES2017"] = 4] = "ES2017";
7005
+ ScriptTarget12[ScriptTarget12["ES2018"] = 5] = "ES2018";
7006
+ ScriptTarget12[ScriptTarget12["ES2019"] = 6] = "ES2019";
7007
+ ScriptTarget12[ScriptTarget12["ES2020"] = 7] = "ES2020";
7008
+ ScriptTarget12[ScriptTarget12["ES2021"] = 8] = "ES2021";
7009
+ ScriptTarget12[ScriptTarget12["ES2022"] = 9] = "ES2022";
7010
+ ScriptTarget12[ScriptTarget12["ES2023"] = 10] = "ES2023";
7011
+ ScriptTarget12[ScriptTarget12["ESNext"] = 99] = "ESNext";
7012
+ ScriptTarget12[ScriptTarget12["JSON"] = 100] = "JSON";
7013
+ ScriptTarget12[ScriptTarget12["Latest"] = 99 /* ESNext */] = "Latest";
7014
+ return ScriptTarget12;
7014
7015
  })(ScriptTarget || {});
7015
7016
  var LanguageVariant = /* @__PURE__ */ ((LanguageVariant4) => {
7016
7017
  LanguageVariant4[LanguageVariant4["Standard"] = 0] = "Standard";
@@ -7023,6 +7024,7 @@ var WatchDirectoryFlags = /* @__PURE__ */ ((WatchDirectoryFlags3) => {
7023
7024
  return WatchDirectoryFlags3;
7024
7025
  })(WatchDirectoryFlags || {});
7025
7026
  var CharacterCodes = /* @__PURE__ */ ((CharacterCodes2) => {
7027
+ CharacterCodes2[CharacterCodes2["EOF"] = -1] = "EOF";
7026
7028
  CharacterCodes2[CharacterCodes2["nullCharacter"] = 0] = "nullCharacter";
7027
7029
  CharacterCodes2[CharacterCodes2["maxAsciiCharacter"] = 127] = "maxAsciiCharacter";
7028
7030
  CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
@@ -9815,7 +9817,7 @@ var Diagnostics = {
9815
9817
  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."),
9816
9818
  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."),
9817
9819
  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."),
9818
- Expected_a_class_set_oprand: diag(1520, 1 /* Error */, "Expected_a_class_set_oprand_1520", "Expected a class set oprand."),
9820
+ Expected_a_class_set_operand: diag(1520, 1 /* Error */, "Expected_a_class_set_operand_1520", "Expected a class set operand."),
9819
9821
  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."),
9820
9822
  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?"),
9821
9823
  Expected_a_Unicode_property_name: diag(1523, 1 /* Error */, "Expected_a_Unicode_property_name_1523", "Expected a Unicode property name."),
@@ -11328,6 +11330,16 @@ var Diagnostics = {
11328
11330
  Export_0_from_module_1: diag(90059, 3 /* Message */, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
11329
11331
  Export_all_referenced_locals: diag(90060, 3 /* Message */, "Export_all_referenced_locals_90060", "Export all referenced locals"),
11330
11332
  Update_modifiers_of_0: diag(90061, 3 /* Message */, "Update_modifiers_of_0_90061", "Update modifiers of '{0}'"),
11333
+ Add_annotation_of_type_0: diag(90062, 3 /* Message */, "Add_annotation_of_type_0_90062", "Add annotation of type '{0}'"),
11334
+ Add_return_type_0: diag(90063, 3 /* Message */, "Add_return_type_0_90063", "Add return type '{0}'"),
11335
+ Extract_base_class_to_variable: diag(90064, 3 /* Message */, "Extract_base_class_to_variable_90064", "Extract base class to variable"),
11336
+ Extract_default_export_to_variable: diag(90065, 3 /* Message */, "Extract_default_export_to_variable_90065", "Extract default export to variable"),
11337
+ Extract_binding_expressions_to_variable: diag(90066, 3 /* Message */, "Extract_binding_expressions_to_variable_90066", "Extract binding expressions to variable"),
11338
+ Add_all_missing_type_annotations: diag(90067, 3 /* Message */, "Add_all_missing_type_annotations_90067", "Add all missing type annotations"),
11339
+ Add_satisfies_and_an_inline_type_assertion_with_0: diag(90068, 3 /* Message */, "Add_satisfies_and_an_inline_type_assertion_with_0_90068", "Add satisfies and an inline type assertion with '{0}'"),
11340
+ Extract_to_variable_and_replace_with_0_as_typeof_0: diag(90069, 3 /* Message */, "Extract_to_variable_and_replace_with_0_as_typeof_0_90069", "Extract to variable and replace with '{0} as typeof {0}'"),
11341
+ Mark_array_literal_as_const: diag(90070, 3 /* Message */, "Mark_array_literal_as_const_90070", "Mark array literal as const"),
11342
+ Annotate_types_of_properties_expando_function_in_a_namespace: diag(90071, 3 /* Message */, "Annotate_types_of_properties_expando_function_in_a_namespace_90071", "Annotate types of properties expando function in a namespace"),
11331
11343
  Convert_function_to_an_ES2015_class: diag(95001, 3 /* Message */, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
11332
11344
  Convert_0_to_1_in_0: diag(95003, 3 /* Message */, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
11333
11345
  Extract_to_0_in_1: diag(95004, 3 /* Message */, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -12325,6 +12337,18 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12325
12337
  });
12326
12338
  }
12327
12339
  return scanner2;
12340
+ function codePointUnchecked(pos2) {
12341
+ return codePointAt(text, pos2);
12342
+ }
12343
+ function codePointChecked(pos2) {
12344
+ return pos2 >= 0 && pos2 < end ? codePointUnchecked(pos2) : -1 /* EOF */;
12345
+ }
12346
+ function charCodeUnchecked(pos2) {
12347
+ return text.charCodeAt(pos2);
12348
+ }
12349
+ function charCodeChecked(pos2) {
12350
+ return pos2 >= 0 && pos2 < end ? charCodeUnchecked(pos2) : -1 /* EOF */;
12351
+ }
12328
12352
  function error2(message, errPos = pos, length3, arg0) {
12329
12353
  if (onError) {
12330
12354
  const oldPos = pos;
@@ -12339,7 +12363,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12339
12363
  let isPreviousTokenSeparator = false;
12340
12364
  let result = "";
12341
12365
  while (true) {
12342
- const ch = text.charCodeAt(pos);
12366
+ const ch = charCodeUnchecked(pos);
12343
12367
  if (ch === 95 /* _ */) {
12344
12368
  tokenFlags |= 512 /* ContainsSeparator */;
12345
12369
  if (allowSeparator) {
@@ -12366,7 +12390,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12366
12390
  }
12367
12391
  break;
12368
12392
  }
12369
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
12393
+ if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
12370
12394
  tokenFlags |= 16384 /* ContainsInvalidSeparator */;
12371
12395
  error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
12372
12396
  }
@@ -12375,9 +12399,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12375
12399
  function scanNumber() {
12376
12400
  let start2 = pos;
12377
12401
  let mainFragment;
12378
- if (text.charCodeAt(pos) === 48 /* _0 */) {
12402
+ if (charCodeUnchecked(pos) === 48 /* _0 */) {
12379
12403
  pos++;
12380
- if (text.charCodeAt(pos) === 95 /* _ */) {
12404
+ if (charCodeUnchecked(pos) === 95 /* _ */) {
12381
12405
  tokenFlags |= 512 /* ContainsSeparator */ | 16384 /* ContainsInvalidSeparator */;
12382
12406
  error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
12383
12407
  pos--;
@@ -12402,15 +12426,15 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12402
12426
  }
12403
12427
  let decimalFragment;
12404
12428
  let scientificFragment;
12405
- if (text.charCodeAt(pos) === 46 /* dot */) {
12429
+ if (charCodeUnchecked(pos) === 46 /* dot */) {
12406
12430
  pos++;
12407
12431
  decimalFragment = scanNumberFragment();
12408
12432
  }
12409
12433
  let end2 = pos;
12410
- if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) {
12434
+ if (charCodeUnchecked(pos) === 69 /* E */ || charCodeUnchecked(pos) === 101 /* e */) {
12411
12435
  pos++;
12412
12436
  tokenFlags |= 16 /* Scientific */;
12413
- if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */)
12437
+ if (charCodeUnchecked(pos) === 43 /* plus */ || charCodeUnchecked(pos) === 45 /* minus */)
12414
12438
  pos++;
12415
12439
  const preNumericPart = pos;
12416
12440
  const finalFragment = scanNumberFragment();
@@ -12450,7 +12474,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12450
12474
  }
12451
12475
  }
12452
12476
  function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
12453
- if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
12477
+ if (!isIdentifierStart(codePointUnchecked(pos), languageVersion)) {
12454
12478
  return;
12455
12479
  }
12456
12480
  const identifierStart = pos;
@@ -12469,8 +12493,8 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12469
12493
  function scanDigits() {
12470
12494
  const start2 = pos;
12471
12495
  let isOctal = true;
12472
- while (isDigit(text.charCodeAt(pos))) {
12473
- if (!isOctalDigit(text.charCodeAt(pos))) {
12496
+ while (isDigit(charCodeChecked(pos))) {
12497
+ if (!isOctalDigit(charCodeUnchecked(pos))) {
12474
12498
  isOctal = false;
12475
12499
  }
12476
12500
  pos++;
@@ -12502,7 +12526,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12502
12526
  let allowSeparator = false;
12503
12527
  let isPreviousTokenSeparator = false;
12504
12528
  while (valueChars.length < minCount || scanAsManyAsPossible) {
12505
- let ch = text.charCodeAt(pos);
12529
+ let ch = charCodeUnchecked(pos);
12506
12530
  if (canHaveSeparators && ch === 95 /* _ */) {
12507
12531
  tokenFlags |= 512 /* ContainsSeparator */;
12508
12532
  if (allowSeparator) {
@@ -12529,13 +12553,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12529
12553
  if (valueChars.length < minCount) {
12530
12554
  valueChars = [];
12531
12555
  }
12532
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
12556
+ if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
12533
12557
  error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
12534
12558
  }
12535
12559
  return String.fromCharCode(...valueChars);
12536
12560
  }
12537
12561
  function scanString(jsxAttributeString = false) {
12538
- const quote2 = text.charCodeAt(pos);
12562
+ const quote2 = charCodeUnchecked(pos);
12539
12563
  pos++;
12540
12564
  let result = "";
12541
12565
  let start2 = pos;
@@ -12546,7 +12570,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12546
12570
  error2(Diagnostics.Unterminated_string_literal);
12547
12571
  break;
12548
12572
  }
12549
- const ch = text.charCodeAt(pos);
12573
+ const ch = charCodeUnchecked(pos);
12550
12574
  if (ch === quote2) {
12551
12575
  result += text.substring(start2, pos);
12552
12576
  pos++;
@@ -12574,7 +12598,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12574
12598
  return result;
12575
12599
  }
12576
12600
  function scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError) {
12577
- const startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */;
12601
+ const startedWithBacktick = charCodeUnchecked(pos) === 96 /* backtick */;
12578
12602
  pos++;
12579
12603
  let start2 = pos;
12580
12604
  let contents = "";
@@ -12587,14 +12611,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12587
12611
  resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
12588
12612
  break;
12589
12613
  }
12590
- const currChar = text.charCodeAt(pos);
12614
+ const currChar = charCodeUnchecked(pos);
12591
12615
  if (currChar === 96 /* backtick */) {
12592
12616
  contents += text.substring(start2, pos);
12593
12617
  pos++;
12594
12618
  resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
12595
12619
  break;
12596
12620
  }
12597
- if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) {
12621
+ if (currChar === 36 /* $ */ && pos + 1 < end && charCodeUnchecked(pos + 1) === 123 /* openBrace */) {
12598
12622
  contents += text.substring(start2, pos);
12599
12623
  pos += 2;
12600
12624
  resultingToken = startedWithBacktick ? 16 /* TemplateHead */ : 17 /* TemplateMiddle */;
@@ -12613,7 +12637,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12613
12637
  if (currChar === 13 /* carriageReturn */) {
12614
12638
  contents += text.substring(start2, pos);
12615
12639
  pos++;
12616
- if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
12640
+ if (pos < end && charCodeUnchecked(pos) === 10 /* lineFeed */) {
12617
12641
  pos++;
12618
12642
  }
12619
12643
  contents += "\n";
@@ -12633,24 +12657,24 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12633
12657
  error2(Diagnostics.Unexpected_end_of_text);
12634
12658
  return "";
12635
12659
  }
12636
- const ch = text.charCodeAt(pos);
12660
+ const ch = charCodeUnchecked(pos);
12637
12661
  pos++;
12638
12662
  switch (ch) {
12639
12663
  case 48 /* _0 */:
12640
- if (pos >= end || !isDigit(text.charCodeAt(pos))) {
12664
+ if (pos >= end || !isDigit(charCodeUnchecked(pos))) {
12641
12665
  return "\0";
12642
12666
  }
12643
12667
  case 49 /* _1 */:
12644
12668
  case 50 /* _2 */:
12645
12669
  case 51 /* _3 */:
12646
- if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
12670
+ if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
12647
12671
  pos++;
12648
12672
  }
12649
12673
  case 52 /* _4 */:
12650
12674
  case 53 /* _5 */:
12651
12675
  case 54 /* _6 */:
12652
12676
  case 55 /* _7 */:
12653
- if (pos < end && isOctalDigit(text.charCodeAt(pos))) {
12677
+ if (pos < end && isOctalDigit(charCodeUnchecked(pos))) {
12654
12678
  pos++;
12655
12679
  }
12656
12680
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
@@ -12687,12 +12711,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12687
12711
  case 34 /* doubleQuote */:
12688
12712
  return '"';
12689
12713
  case 117 /* u */:
12690
- if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
12714
+ if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && charCodeUnchecked(pos) === 123 /* openBrace */) {
12691
12715
  pos -= 2;
12692
12716
  return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
12693
12717
  }
12694
12718
  for (; pos < start2 + 6; pos++) {
12695
- if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
12719
+ if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
12696
12720
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12697
12721
  if (isRegularExpression || shouldEmitInvalidEscapeError) {
12698
12722
  error2(Diagnostics.Hexadecimal_digit_expected);
@@ -12703,11 +12727,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12703
12727
  tokenFlags |= 1024 /* UnicodeEscape */;
12704
12728
  const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
12705
12729
  const escapedValueString = String.fromCharCode(escapedValue);
12706
- if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && text.charCodeAt(pos + 2) !== 123 /* openBrace */) {
12730
+ if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && charCodeUnchecked(pos + 2) !== 123 /* openBrace */) {
12707
12731
  const nextStart = pos;
12708
12732
  let nextPos = pos + 2;
12709
12733
  for (; nextPos < nextStart + 6; nextPos++) {
12710
- if (!isHexDigit(text.charCodeAt(pos))) {
12734
+ if (!isHexDigit(charCodeUnchecked(pos))) {
12711
12735
  return escapedValueString;
12712
12736
  }
12713
12737
  }
@@ -12720,7 +12744,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12720
12744
  return escapedValueString;
12721
12745
  case 120 /* x */:
12722
12746
  for (; pos < start2 + 4; pos++) {
12723
- if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
12747
+ if (!(pos < end && isHexDigit(charCodeUnchecked(pos)))) {
12724
12748
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
12725
12749
  if (isRegularExpression || shouldEmitInvalidEscapeError) {
12726
12750
  error2(Diagnostics.Hexadecimal_digit_expected);
@@ -12731,7 +12755,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12731
12755
  tokenFlags |= 4096 /* HexEscape */;
12732
12756
  return String.fromCharCode(parseInt(text.substring(start2 + 2, pos), 16));
12733
12757
  case 13 /* carriageReturn */:
12734
- if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) {
12758
+ if (pos < end && charCodeUnchecked(pos) === 10 /* lineFeed */) {
12735
12759
  pos++;
12736
12760
  }
12737
12761
  case 10 /* lineFeed */:
@@ -12772,7 +12796,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12772
12796
  error2(Diagnostics.Unexpected_end_of_text);
12773
12797
  }
12774
12798
  isInvalidExtendedEscape = true;
12775
- } else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
12799
+ } else if (charCodeUnchecked(pos) === 125 /* closeBrace */) {
12776
12800
  pos++;
12777
12801
  } else {
12778
12802
  if (shouldEmitInvalidEscapeError) {
@@ -12788,7 +12812,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12788
12812
  return utf16EncodeAsString(escapedValue);
12789
12813
  }
12790
12814
  function peekUnicodeEscape() {
12791
- if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) {
12815
+ if (pos + 5 < end && charCodeUnchecked(pos + 1) === 117 /* u */) {
12792
12816
  const start2 = pos;
12793
12817
  pos += 2;
12794
12818
  const value = scanExactNumberOfHexDigits(
@@ -12802,7 +12826,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12802
12826
  return -1;
12803
12827
  }
12804
12828
  function peekExtendedUnicodeEscape() {
12805
- if (codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) {
12829
+ if (codePointUnchecked(pos + 1) === 117 /* u */ && codePointUnchecked(pos + 2) === 123 /* openBrace */) {
12806
12830
  const start2 = pos;
12807
12831
  pos += 3;
12808
12832
  const escapedValueString = scanMinimumNumberOfHexDigits(
@@ -12820,7 +12844,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12820
12844
  let result = "";
12821
12845
  let start2 = pos;
12822
12846
  while (pos < end) {
12823
- let ch = codePointAt(text, pos);
12847
+ let ch = codePointUnchecked(pos);
12824
12848
  if (isIdentifierPart(ch, languageVersion)) {
12825
12849
  pos += charSize(ch);
12826
12850
  } else if (ch === 92 /* backslash */) {
@@ -12867,7 +12891,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12867
12891
  let separatorAllowed = false;
12868
12892
  let isPreviousTokenSeparator = false;
12869
12893
  while (true) {
12870
- const ch = text.charCodeAt(pos);
12894
+ const ch = charCodeUnchecked(pos);
12871
12895
  if (ch === 95 /* _ */) {
12872
12896
  tokenFlags |= 512 /* ContainsSeparator */;
12873
12897
  if (separatorAllowed) {
@@ -12889,13 +12913,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12889
12913
  pos++;
12890
12914
  isPreviousTokenSeparator = false;
12891
12915
  }
12892
- if (text.charCodeAt(pos - 1) === 95 /* _ */) {
12916
+ if (charCodeUnchecked(pos - 1) === 95 /* _ */) {
12893
12917
  error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
12894
12918
  }
12895
12919
  return value;
12896
12920
  }
12897
12921
  function checkBigIntSuffix() {
12898
- if (text.charCodeAt(pos) === 110 /* n */) {
12922
+ if (charCodeUnchecked(pos) === 110 /* n */) {
12899
12923
  tokenValue += "n";
12900
12924
  if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) {
12901
12925
  tokenValue = parsePseudoBigInt(tokenValue) + "n";
@@ -12917,7 +12941,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12917
12941
  if (pos >= end) {
12918
12942
  return token = 1 /* EndOfFileToken */;
12919
12943
  }
12920
- const ch = codePointAt(text, pos);
12944
+ const ch = codePointUnchecked(pos);
12921
12945
  if (pos === 0) {
12922
12946
  if (ch === 35 /* hash */ && isShebangTrivia(text, pos)) {
12923
12947
  pos = scanShebangTrivia(text, pos);
@@ -12936,7 +12960,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12936
12960
  pos++;
12937
12961
  continue;
12938
12962
  } else {
12939
- if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) {
12963
+ if (ch === 13 /* carriageReturn */ && pos + 1 < end && charCodeUnchecked(pos + 1) === 10 /* lineFeed */) {
12940
12964
  pos += 2;
12941
12965
  } else {
12942
12966
  pos++;
@@ -12969,14 +12993,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12969
12993
  pos++;
12970
12994
  continue;
12971
12995
  } else {
12972
- while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
12996
+ while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
12973
12997
  pos++;
12974
12998
  }
12975
12999
  return token = 5 /* WhitespaceTrivia */;
12976
13000
  }
12977
13001
  case 33 /* exclamation */:
12978
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
12979
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13002
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13003
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
12980
13004
  return pos += 3, token = 38 /* ExclamationEqualsEqualsToken */;
12981
13005
  }
12982
13006
  return pos += 2, token = 36 /* ExclamationEqualsToken */;
@@ -12993,19 +13017,19 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
12993
13017
  false
12994
13018
  );
12995
13019
  case 37 /* percent */:
12996
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13020
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
12997
13021
  return pos += 2, token = 70 /* PercentEqualsToken */;
12998
13022
  }
12999
13023
  pos++;
13000
13024
  return token = 45 /* PercentToken */;
13001
13025
  case 38 /* ampersand */:
13002
- if (text.charCodeAt(pos + 1) === 38 /* ampersand */) {
13003
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13026
+ if (charCodeUnchecked(pos + 1) === 38 /* ampersand */) {
13027
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13004
13028
  return pos += 3, token = 77 /* AmpersandAmpersandEqualsToken */;
13005
13029
  }
13006
13030
  return pos += 2, token = 56 /* AmpersandAmpersandToken */;
13007
13031
  }
13008
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13032
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13009
13033
  return pos += 2, token = 74 /* AmpersandEqualsToken */;
13010
13034
  }
13011
13035
  pos++;
@@ -13017,11 +13041,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13017
13041
  pos++;
13018
13042
  return token = 22 /* CloseParenToken */;
13019
13043
  case 42 /* asterisk */:
13020
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13044
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13021
13045
  return pos += 2, token = 67 /* AsteriskEqualsToken */;
13022
13046
  }
13023
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
13024
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13047
+ if (charCodeUnchecked(pos + 1) === 42 /* asterisk */) {
13048
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13025
13049
  return pos += 3, token = 68 /* AsteriskAsteriskEqualsToken */;
13026
13050
  }
13027
13051
  return pos += 2, token = 43 /* AsteriskAsteriskToken */;
@@ -13033,10 +13057,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13033
13057
  }
13034
13058
  return token = 42 /* AsteriskToken */;
13035
13059
  case 43 /* plus */:
13036
- if (text.charCodeAt(pos + 1) === 43 /* plus */) {
13060
+ if (charCodeUnchecked(pos + 1) === 43 /* plus */) {
13037
13061
  return pos += 2, token = 46 /* PlusPlusToken */;
13038
13062
  }
13039
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13063
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13040
13064
  return pos += 2, token = 65 /* PlusEqualsToken */;
13041
13065
  }
13042
13066
  pos++;
@@ -13045,29 +13069,29 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13045
13069
  pos++;
13046
13070
  return token = 28 /* CommaToken */;
13047
13071
  case 45 /* minus */:
13048
- if (text.charCodeAt(pos + 1) === 45 /* minus */) {
13072
+ if (charCodeUnchecked(pos + 1) === 45 /* minus */) {
13049
13073
  return pos += 2, token = 47 /* MinusMinusToken */;
13050
13074
  }
13051
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13075
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13052
13076
  return pos += 2, token = 66 /* MinusEqualsToken */;
13053
13077
  }
13054
13078
  pos++;
13055
13079
  return token = 41 /* MinusToken */;
13056
13080
  case 46 /* dot */:
13057
- if (isDigit(text.charCodeAt(pos + 1))) {
13081
+ if (isDigit(charCodeUnchecked(pos + 1))) {
13058
13082
  scanNumber();
13059
13083
  return token = 9 /* NumericLiteral */;
13060
13084
  }
13061
- if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) {
13085
+ if (charCodeUnchecked(pos + 1) === 46 /* dot */ && charCodeUnchecked(pos + 2) === 46 /* dot */) {
13062
13086
  return pos += 3, token = 26 /* DotDotDotToken */;
13063
13087
  }
13064
13088
  pos++;
13065
13089
  return token = 25 /* DotToken */;
13066
13090
  case 47 /* slash */:
13067
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
13091
+ if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
13068
13092
  pos += 2;
13069
13093
  while (pos < end) {
13070
- if (isLineBreak(text.charCodeAt(pos))) {
13094
+ if (isLineBreak(charCodeUnchecked(pos))) {
13071
13095
  break;
13072
13096
  }
13073
13097
  pos++;
@@ -13084,14 +13108,14 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13084
13108
  return token = 2 /* SingleLineCommentTrivia */;
13085
13109
  }
13086
13110
  }
13087
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
13111
+ if (charCodeUnchecked(pos + 1) === 42 /* asterisk */) {
13088
13112
  pos += 2;
13089
- const isJSDoc2 = text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */;
13113
+ const isJSDoc2 = charCodeUnchecked(pos) === 42 /* asterisk */ && charCodeUnchecked(pos + 1) !== 47 /* slash */;
13090
13114
  let commentClosed = false;
13091
13115
  let lastLineStart = tokenStart;
13092
13116
  while (pos < end) {
13093
- const ch2 = text.charCodeAt(pos);
13094
- if (ch2 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
13117
+ const ch2 = charCodeUnchecked(pos);
13118
+ if (ch2 === 42 /* asterisk */ && charCodeUnchecked(pos + 1) === 47 /* slash */) {
13095
13119
  pos += 2;
13096
13120
  commentClosed = true;
13097
13121
  break;
@@ -13118,13 +13142,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13118
13142
  return token = 3 /* MultiLineCommentTrivia */;
13119
13143
  }
13120
13144
  }
13121
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13145
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13122
13146
  return pos += 2, token = 69 /* SlashEqualsToken */;
13123
13147
  }
13124
13148
  pos++;
13125
13149
  return token = 44 /* SlashToken */;
13126
13150
  case 48 /* _0 */:
13127
- if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) {
13151
+ if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 88 /* X */ || charCodeUnchecked(pos + 1) === 120 /* x */)) {
13128
13152
  pos += 2;
13129
13153
  tokenValue = scanMinimumNumberOfHexDigits(
13130
13154
  1,
@@ -13138,7 +13162,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13138
13162
  tokenValue = "0x" + tokenValue;
13139
13163
  tokenFlags |= 64 /* HexSpecifier */;
13140
13164
  return token = checkBigIntSuffix();
13141
- } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) {
13165
+ } else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 66 /* B */ || charCodeUnchecked(pos + 1) === 98 /* b */)) {
13142
13166
  pos += 2;
13143
13167
  tokenValue = scanBinaryOrOctalDigits(
13144
13168
  /* base */
@@ -13151,7 +13175,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13151
13175
  tokenValue = "0b" + tokenValue;
13152
13176
  tokenFlags |= 128 /* BinarySpecifier */;
13153
13177
  return token = checkBigIntSuffix();
13154
- } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) {
13178
+ } else if (pos + 2 < end && (charCodeUnchecked(pos + 1) === 79 /* O */ || charCodeUnchecked(pos + 1) === 111 /* o */)) {
13155
13179
  pos += 2;
13156
13180
  tokenValue = scanBinaryOrOctalDigits(
13157
13181
  /* base */
@@ -13190,16 +13214,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13190
13214
  return token = 7 /* ConflictMarkerTrivia */;
13191
13215
  }
13192
13216
  }
13193
- if (text.charCodeAt(pos + 1) === 60 /* lessThan */) {
13194
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13217
+ if (charCodeUnchecked(pos + 1) === 60 /* lessThan */) {
13218
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13195
13219
  return pos += 3, token = 71 /* LessThanLessThanEqualsToken */;
13196
13220
  }
13197
13221
  return pos += 2, token = 48 /* LessThanLessThanToken */;
13198
13222
  }
13199
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13223
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13200
13224
  return pos += 2, token = 33 /* LessThanEqualsToken */;
13201
13225
  }
13202
- if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) {
13226
+ if (languageVariant === 1 /* JSX */ && charCodeUnchecked(pos + 1) === 47 /* slash */ && charCodeUnchecked(pos + 2) !== 42 /* asterisk */) {
13203
13227
  return pos += 2, token = 31 /* LessThanSlashToken */;
13204
13228
  }
13205
13229
  pos++;
@@ -13213,13 +13237,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13213
13237
  return token = 7 /* ConflictMarkerTrivia */;
13214
13238
  }
13215
13239
  }
13216
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13217
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13240
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13241
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13218
13242
  return pos += 3, token = 37 /* EqualsEqualsEqualsToken */;
13219
13243
  }
13220
13244
  return pos += 2, token = 35 /* EqualsEqualsToken */;
13221
13245
  }
13222
- if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
13246
+ if (charCodeUnchecked(pos + 1) === 62 /* greaterThan */) {
13223
13247
  return pos += 2, token = 39 /* EqualsGreaterThanToken */;
13224
13248
  }
13225
13249
  pos++;
@@ -13236,11 +13260,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13236
13260
  pos++;
13237
13261
  return token = 32 /* GreaterThanToken */;
13238
13262
  case 63 /* question */:
13239
- if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) {
13263
+ if (charCodeUnchecked(pos + 1) === 46 /* dot */ && !isDigit(charCodeUnchecked(pos + 2))) {
13240
13264
  return pos += 2, token = 29 /* QuestionDotToken */;
13241
13265
  }
13242
- if (text.charCodeAt(pos + 1) === 63 /* question */) {
13243
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13266
+ if (charCodeUnchecked(pos + 1) === 63 /* question */) {
13267
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13244
13268
  return pos += 3, token = 78 /* QuestionQuestionEqualsToken */;
13245
13269
  }
13246
13270
  return pos += 2, token = 61 /* QuestionQuestionToken */;
@@ -13254,7 +13278,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13254
13278
  pos++;
13255
13279
  return token = 24 /* CloseBracketToken */;
13256
13280
  case 94 /* caret */:
13257
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13281
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13258
13282
  return pos += 2, token = 79 /* CaretEqualsToken */;
13259
13283
  }
13260
13284
  pos++;
@@ -13271,13 +13295,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13271
13295
  return token = 7 /* ConflictMarkerTrivia */;
13272
13296
  }
13273
13297
  }
13274
- if (text.charCodeAt(pos + 1) === 124 /* bar */) {
13275
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13298
+ if (charCodeUnchecked(pos + 1) === 124 /* bar */) {
13299
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13276
13300
  return pos += 3, token = 76 /* BarBarEqualsToken */;
13277
13301
  }
13278
13302
  return pos += 2, token = 57 /* BarBarToken */;
13279
13303
  }
13280
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13304
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13281
13305
  return pos += 2, token = 75 /* BarEqualsToken */;
13282
13306
  }
13283
13307
  pos++;
@@ -13316,7 +13340,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13316
13340
  pos++;
13317
13341
  return token = 0 /* Unknown */;
13318
13342
  }
13319
- const charAfterHash = codePointAt(text, pos + 1);
13343
+ const charAfterHash = codePointUnchecked(pos + 1);
13320
13344
  if (charAfterHash === 92 /* backslash */) {
13321
13345
  pos++;
13322
13346
  const extendedCookedChar2 = peekExtendedUnicodeEscape();
@@ -13386,7 +13410,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13386
13410
  Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
13387
13411
  pos = tokenStart = fullStartPos;
13388
13412
  tokenFlags = 0;
13389
- const ch = codePointAt(text, pos);
13413
+ const ch = codePointUnchecked(pos);
13390
13414
  const identifierKind = scanIdentifier(ch, 99 /* ESNext */);
13391
13415
  if (identifierKind) {
13392
13416
  return token = identifierKind;
@@ -13398,7 +13422,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13398
13422
  let ch = startCharacter;
13399
13423
  if (isIdentifierStart(ch, languageVersion2)) {
13400
13424
  pos += charSize(ch);
13401
- while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion2))
13425
+ while (pos < end && isIdentifierPart(ch = codePointUnchecked(pos), languageVersion2))
13402
13426
  pos += charSize(ch);
13403
13427
  tokenValue = text.substring(tokenStart, pos);
13404
13428
  if (ch === 92 /* backslash */) {
@@ -13409,20 +13433,20 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13409
13433
  }
13410
13434
  function reScanGreaterToken() {
13411
13435
  if (token === 32 /* GreaterThanToken */) {
13412
- if (text.charCodeAt(pos) === 62 /* greaterThan */) {
13413
- if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) {
13414
- if (text.charCodeAt(pos + 2) === 61 /* equals */) {
13436
+ if (charCodeUnchecked(pos) === 62 /* greaterThan */) {
13437
+ if (charCodeUnchecked(pos + 1) === 62 /* greaterThan */) {
13438
+ if (charCodeUnchecked(pos + 2) === 61 /* equals */) {
13415
13439
  return pos += 3, token = 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */;
13416
13440
  }
13417
13441
  return pos += 2, token = 50 /* GreaterThanGreaterThanGreaterThanToken */;
13418
13442
  }
13419
- if (text.charCodeAt(pos + 1) === 61 /* equals */) {
13443
+ if (charCodeUnchecked(pos + 1) === 61 /* equals */) {
13420
13444
  return pos += 2, token = 72 /* GreaterThanGreaterThanEqualsToken */;
13421
13445
  }
13422
13446
  pos++;
13423
13447
  return token = 49 /* GreaterThanGreaterThanToken */;
13424
13448
  }
13425
- if (text.charCodeAt(pos) === 61 /* equals */) {
13449
+ if (charCodeUnchecked(pos) === 61 /* equals */) {
13426
13450
  pos++;
13427
13451
  return token = 34 /* GreaterThanEqualsToken */;
13428
13452
  }
@@ -13445,7 +13469,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13445
13469
  error2(Diagnostics.Unterminated_regular_expression_literal);
13446
13470
  break;
13447
13471
  }
13448
- const ch = text.charCodeAt(p);
13472
+ const ch = charCodeUnchecked(p);
13449
13473
  if (isLineBreak(ch)) {
13450
13474
  tokenFlags |= 4 /* Unterminated */;
13451
13475
  error2(Diagnostics.Unterminated_regular_expression_literal);
@@ -13469,7 +13493,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13469
13493
  const endOfBody = p - (isUnterminated ? 0 : 1);
13470
13494
  let regExpFlags = 0 /* None */;
13471
13495
  while (p < end) {
13472
- const ch = text.charCodeAt(p);
13496
+ const ch = charCodeUnchecked(p);
13473
13497
  if (!isIdentifierPart(ch, languageVersion)) {
13474
13498
  break;
13475
13499
  }
@@ -13488,845 +13512,860 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13488
13512
  }
13489
13513
  p++;
13490
13514
  }
13515
+ pos = p;
13491
13516
  if (reportErrors2) {
13492
- pos = tokenStart + 1;
13493
- const saveTokenPos = tokenStart;
13517
+ const saveTokenStart = tokenStart;
13494
13518
  const saveTokenFlags = tokenFlags;
13519
+ const savePos = pos;
13520
+ const saveEnd = end;
13521
+ pos = tokenStart + 1;
13522
+ end = endOfBody;
13495
13523
  scanRegularExpressionWorker(
13496
- text,
13497
- endOfBody,
13498
13524
  regExpFlags,
13499
13525
  isUnterminated,
13500
13526
  /*annexB*/
13501
13527
  true
13502
13528
  );
13503
- if (!isUnterminated) {
13504
- pos = p;
13505
- }
13506
- tokenStart = saveTokenPos;
13529
+ tokenStart = saveTokenStart;
13507
13530
  tokenFlags = saveTokenFlags;
13508
- } else {
13509
- pos = p;
13531
+ pos = savePos;
13532
+ end = saveEnd;
13510
13533
  }
13511
13534
  tokenValue = text.substring(tokenStart, pos);
13512
13535
  token = 14 /* RegularExpressionLiteral */;
13513
13536
  }
13514
13537
  return token;
13515
- function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated, annexB) {
13516
- const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
13517
- const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
13518
- if (unicodeMode) {
13519
- annexB = false;
13520
- }
13521
- let mayContainStrings = false;
13522
- let numberOfCapturingGroups = 0;
13523
- const groupSpecifiers = /* @__PURE__ */ new Set();
13524
- const groupNameReferences = [];
13525
- const decimalEscapes = [];
13526
- const namedCapturingGroups = [];
13527
- function scanDisjunction(isInGroup) {
13528
- while (true) {
13529
- namedCapturingGroups.push(/* @__PURE__ */ new Set());
13530
- scanAlternative(isInGroup);
13531
- namedCapturingGroups.pop();
13532
- if (text2.charCodeAt(pos) !== 124 /* bar */) {
13533
- return;
13534
- }
13535
- pos++;
13538
+ }
13539
+ function scanRegularExpressionWorker(regExpFlags, isUnterminated, annexB) {
13540
+ var unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
13541
+ var unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
13542
+ if (unicodeMode) {
13543
+ annexB = false;
13544
+ }
13545
+ var mayContainStrings = false;
13546
+ var numberOfCapturingGroups = 0;
13547
+ var groupSpecifiers;
13548
+ var groupNameReferences;
13549
+ var decimalEscapes;
13550
+ var namedCapturingGroupsScopeStack = [];
13551
+ var topNamedCapturingGroupsScope;
13552
+ function scanDisjunction(isInGroup) {
13553
+ while (true) {
13554
+ namedCapturingGroupsScopeStack.push(topNamedCapturingGroupsScope);
13555
+ topNamedCapturingGroupsScope = void 0;
13556
+ scanAlternative(isInGroup);
13557
+ topNamedCapturingGroupsScope = namedCapturingGroupsScopeStack.pop();
13558
+ if (charCodeChecked(pos) !== 124 /* bar */) {
13559
+ return;
13536
13560
  }
13561
+ pos++;
13537
13562
  }
13538
- function scanAlternative(isInGroup) {
13539
- let isPreviousTermQuantifiable = false;
13540
- while (pos < end2) {
13541
- const start2 = pos;
13542
- const ch = text2.charCodeAt(pos);
13543
- switch (ch) {
13544
- case 94 /* caret */:
13545
- case 36 /* $ */:
13546
- pos++;
13547
- isPreviousTermQuantifiable = false;
13548
- break;
13549
- case 92 /* backslash */:
13563
+ }
13564
+ function scanAlternative(isInGroup) {
13565
+ let isPreviousTermQuantifiable = false;
13566
+ while (true) {
13567
+ const start2 = pos;
13568
+ const ch = charCodeChecked(pos);
13569
+ switch (ch) {
13570
+ case -1 /* EOF */:
13571
+ return;
13572
+ case 94 /* caret */:
13573
+ case 36 /* $ */:
13574
+ pos++;
13575
+ isPreviousTermQuantifiable = false;
13576
+ break;
13577
+ case 92 /* backslash */:
13578
+ pos++;
13579
+ switch (charCodeChecked(pos)) {
13580
+ case 98 /* b */:
13581
+ case 66 /* B */:
13582
+ pos++;
13583
+ isPreviousTermQuantifiable = false;
13584
+ break;
13585
+ default:
13586
+ scanAtomEscape();
13587
+ isPreviousTermQuantifiable = true;
13588
+ break;
13589
+ }
13590
+ break;
13591
+ case 40 /* openParen */:
13592
+ pos++;
13593
+ if (charCodeChecked(pos) === 63 /* question */) {
13550
13594
  pos++;
13551
- switch (text2.charCodeAt(pos)) {
13552
- case 98 /* b */:
13553
- case 66 /* B */:
13595
+ switch (charCodeChecked(pos)) {
13596
+ case 61 /* equals */:
13597
+ case 33 /* exclamation */:
13554
13598
  pos++;
13555
- isPreviousTermQuantifiable = false;
13599
+ isPreviousTermQuantifiable = annexB;
13556
13600
  break;
13557
- default:
13558
- scanAtomEscape();
13559
- isPreviousTermQuantifiable = true;
13560
- break;
13561
- }
13562
- break;
13563
- case 40 /* openParen */:
13564
- pos++;
13565
- if (text2.charCodeAt(pos) === 63 /* question */) {
13566
- pos++;
13567
- switch (text2.charCodeAt(pos)) {
13568
- case 61 /* equals */:
13569
- case 33 /* exclamation */:
13570
- pos++;
13571
- isPreviousTermQuantifiable = annexB;
13572
- break;
13573
- case 60 /* lessThan */:
13574
- const groupNameStart = pos;
13575
- pos++;
13576
- switch (text2.charCodeAt(pos)) {
13577
- case 61 /* equals */:
13578
- case 33 /* exclamation */:
13579
- pos++;
13580
- isPreviousTermQuantifiable = false;
13581
- break;
13582
- default:
13583
- scanGroupName(
13584
- /*isReference*/
13585
- false
13586
- );
13587
- scanExpectedChar(62 /* greaterThan */);
13588
- if (languageVersion < 5 /* ES2018 */) {
13589
- error2(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
13590
- }
13591
- numberOfCapturingGroups++;
13592
- isPreviousTermQuantifiable = true;
13593
- break;
13594
- }
13595
- break;
13596
- default:
13597
- const start3 = pos;
13598
- const setFlags = scanPatternModifiers(0 /* None */);
13599
- if (text2.charCodeAt(pos) === 45 /* minus */) {
13601
+ case 60 /* lessThan */:
13602
+ const groupNameStart = pos;
13603
+ pos++;
13604
+ switch (charCodeChecked(pos)) {
13605
+ case 61 /* equals */:
13606
+ case 33 /* exclamation */:
13600
13607
  pos++;
13601
- scanPatternModifiers(setFlags);
13602
- if (pos === start3 + 1) {
13603
- error2(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
13608
+ isPreviousTermQuantifiable = false;
13609
+ break;
13610
+ default:
13611
+ scanGroupName(
13612
+ /*isReference*/
13613
+ false
13614
+ );
13615
+ scanExpectedChar(62 /* greaterThan */);
13616
+ if (languageVersion < 5 /* ES2018 */) {
13617
+ error2(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
13604
13618
  }
13619
+ numberOfCapturingGroups++;
13620
+ isPreviousTermQuantifiable = true;
13621
+ break;
13622
+ }
13623
+ break;
13624
+ default:
13625
+ const start3 = pos;
13626
+ const setFlags = scanPatternModifiers(0 /* None */);
13627
+ if (charCodeChecked(pos) === 45 /* minus */) {
13628
+ pos++;
13629
+ scanPatternModifiers(setFlags);
13630
+ if (pos === start3 + 1) {
13631
+ error2(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
13605
13632
  }
13606
- scanExpectedChar(58 /* colon */);
13607
- isPreviousTermQuantifiable = true;
13608
- break;
13609
- }
13610
- } else {
13611
- numberOfCapturingGroups++;
13612
- isPreviousTermQuantifiable = true;
13633
+ }
13634
+ scanExpectedChar(58 /* colon */);
13635
+ isPreviousTermQuantifiable = true;
13636
+ break;
13613
13637
  }
13614
- scanDisjunction(
13615
- /*isInGroup*/
13616
- true
13617
- );
13618
- scanExpectedChar(41 /* closeParen */);
13619
- break;
13620
- case 123 /* openBrace */:
13638
+ } else {
13639
+ numberOfCapturingGroups++;
13640
+ isPreviousTermQuantifiable = true;
13641
+ }
13642
+ scanDisjunction(
13643
+ /*isInGroup*/
13644
+ true
13645
+ );
13646
+ scanExpectedChar(41 /* closeParen */);
13647
+ break;
13648
+ case 123 /* openBrace */:
13649
+ pos++;
13650
+ const digitsStart = pos;
13651
+ scanDigits();
13652
+ const min2 = tokenValue;
13653
+ if (charCodeChecked(pos) === 44 /* comma */) {
13621
13654
  pos++;
13622
- const digitsStart = pos;
13623
13655
  scanDigits();
13624
- const min2 = tokenValue;
13625
- if (text2.charCodeAt(pos) === 44 /* comma */) {
13626
- pos++;
13627
- scanDigits();
13628
- const max = tokenValue;
13629
- if (!min2) {
13630
- if (max || text2.charCodeAt(pos) === 125 /* closeBrace */) {
13631
- error2(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
13632
- } else {
13633
- if (unicodeMode) {
13634
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13635
- }
13636
- isPreviousTermQuantifiable = true;
13637
- break;
13656
+ const max = tokenValue;
13657
+ if (!min2) {
13658
+ if (max || charCodeChecked(pos) === 125 /* closeBrace */) {
13659
+ error2(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
13660
+ } else {
13661
+ if (unicodeMode) {
13662
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13638
13663
  }
13664
+ isPreviousTermQuantifiable = true;
13665
+ break;
13639
13666
  }
13640
- if (max && Number.parseInt(min2) > Number.parseInt(max)) {
13641
- error2(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
13642
- }
13643
- } else if (!min2) {
13644
- if (unicodeMode) {
13645
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13646
- }
13647
- isPreviousTermQuantifiable = true;
13648
- break;
13649
- }
13650
- scanExpectedChar(125 /* closeBrace */);
13651
- pos--;
13652
- case 42 /* asterisk */:
13653
- case 43 /* plus */:
13654
- case 63 /* question */:
13655
- pos++;
13656
- if (text2.charCodeAt(pos) === 63 /* question */) {
13657
- pos++;
13658
- }
13659
- if (!isPreviousTermQuantifiable) {
13660
- error2(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
13661
- }
13662
- isPreviousTermQuantifiable = false;
13663
- break;
13664
- case 46 /* dot */:
13665
- pos++;
13666
- isPreviousTermQuantifiable = true;
13667
- break;
13668
- case 91 /* openBracket */:
13669
- pos++;
13670
- if (unicodeSetsMode) {
13671
- scanClassSetExpression();
13672
- } else {
13673
- scanClassRanges();
13674
13667
  }
13675
- scanExpectedChar(93 /* closeBracket */);
13676
- isPreviousTermQuantifiable = true;
13677
- break;
13678
- case 41 /* closeParen */:
13679
- if (isInGroup) {
13680
- return;
13668
+ if (max && Number.parseInt(min2) > Number.parseInt(max)) {
13669
+ error2(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
13681
13670
  }
13682
- case 93 /* closeBracket */:
13683
- case 125 /* closeBrace */:
13684
- if (isUnterminated && !isInGroup) {
13685
- return;
13686
- }
13687
- if (unicodeMode || ch === 41 /* closeParen */) {
13688
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
13671
+ } else if (!min2) {
13672
+ if (unicodeMode) {
13673
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
13689
13674
  }
13690
- pos++;
13691
13675
  isPreviousTermQuantifiable = true;
13692
13676
  break;
13693
- case 47 /* slash */:
13694
- case 124 /* bar */:
13695
- return;
13696
- default:
13697
- scanSourceCharacter();
13698
- isPreviousTermQuantifiable = true;
13699
- break;
13700
- }
13701
- }
13702
- }
13703
- function scanPatternModifiers(currFlags) {
13704
- while (pos < end2) {
13705
- const ch = text2.charCodeAt(pos);
13706
- if (!isIdentifierPart(ch, languageVersion)) {
13707
- break;
13708
- }
13709
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
13710
- if (flag === void 0) {
13711
- error2(Diagnostics.Unknown_regular_expression_flag, pos, 1);
13712
- } else if (currFlags & flag) {
13713
- error2(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
13714
- } else if (!(flag & 28 /* Modifiers */)) {
13715
- error2(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
13716
- } else {
13717
- currFlags |= flag;
13718
- checkRegularExpressionFlagAvailable(flag, pos);
13719
- }
13720
- pos++;
13721
- }
13722
- return currFlags;
13723
- }
13724
- function scanAtomEscape() {
13725
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
13726
- switch (text2.charCodeAt(pos)) {
13727
- case 107 /* k */:
13677
+ }
13678
+ scanExpectedChar(125 /* closeBrace */);
13679
+ pos--;
13680
+ case 42 /* asterisk */:
13681
+ case 43 /* plus */:
13682
+ case 63 /* question */:
13728
13683
  pos++;
13729
- if (text2.charCodeAt(pos) === 60 /* lessThan */) {
13684
+ if (charCodeChecked(pos) === 63 /* question */) {
13730
13685
  pos++;
13731
- scanGroupName(
13732
- /*isReference*/
13733
- true
13734
- );
13735
- scanExpectedChar(62 /* greaterThan */);
13736
- } else if (unicodeMode) {
13737
- error2(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
13738
13686
  }
13739
- break;
13740
- case 113 /* q */:
13741
- if (unicodeSetsMode) {
13742
- pos++;
13743
- error2(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
13744
- break;
13687
+ if (!isPreviousTermQuantifiable) {
13688
+ error2(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
13745
13689
  }
13746
- default:
13747
- Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
13748
- /*atomEscape*/
13749
- true
13750
- ));
13690
+ isPreviousTermQuantifiable = false;
13751
13691
  break;
13752
- }
13753
- }
13754
- function scanDecimalEscape() {
13755
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
13756
- const ch = text2.charCodeAt(pos);
13757
- if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
13758
- const start2 = pos;
13759
- scanDigits();
13760
- decimalEscapes.push({ pos: start2, end: pos, value: +tokenValue });
13761
- return true;
13762
- }
13763
- return false;
13764
- }
13765
- function scanCharacterEscape(atomEscape) {
13766
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
13767
- let ch = text2.charCodeAt(pos);
13768
- switch (ch) {
13769
- case 99 /* c */:
13692
+ case 46 /* dot */:
13770
13693
  pos++;
13771
- ch = text2.charCodeAt(pos);
13772
- if (isASCIILetter(ch)) {
13773
- pos++;
13774
- return String.fromCharCode(ch & 31);
13775
- }
13776
- if (unicodeMode) {
13777
- error2(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
13778
- } else if (atomEscape && annexB) {
13779
- pos--;
13780
- return "\\";
13694
+ isPreviousTermQuantifiable = true;
13695
+ break;
13696
+ case 91 /* openBracket */:
13697
+ pos++;
13698
+ if (unicodeSetsMode) {
13699
+ scanClassSetExpression();
13700
+ } else {
13701
+ scanClassRanges();
13781
13702
  }
13782
- return String.fromCharCode(ch);
13783
- case 94 /* caret */:
13784
- case 36 /* $ */:
13785
- case 47 /* slash */:
13786
- case 92 /* backslash */:
13787
- case 46 /* dot */:
13788
- case 42 /* asterisk */:
13789
- case 43 /* plus */:
13790
- case 63 /* question */:
13791
- case 40 /* openParen */:
13703
+ scanExpectedChar(93 /* closeBracket */);
13704
+ isPreviousTermQuantifiable = true;
13705
+ break;
13792
13706
  case 41 /* closeParen */:
13793
- case 91 /* openBracket */:
13707
+ if (isInGroup) {
13708
+ return;
13709
+ }
13794
13710
  case 93 /* closeBracket */:
13795
- case 123 /* openBrace */:
13796
13711
  case 125 /* closeBrace */:
13797
- case 124 /* bar */:
13712
+ if (isUnterminated && !isInGroup) {
13713
+ return;
13714
+ }
13715
+ if (unicodeMode || ch === 41 /* closeParen */) {
13716
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
13717
+ }
13798
13718
  pos++;
13799
- return String.fromCharCode(ch);
13719
+ isPreviousTermQuantifiable = true;
13720
+ break;
13721
+ case 47 /* slash */:
13722
+ case 124 /* bar */:
13723
+ return;
13800
13724
  default:
13801
- if (pos >= end2) {
13802
- error2(Diagnostics.Undetermined_character_escape, pos - 1, 1, ch);
13803
- return "\\";
13804
- }
13805
- pos--;
13806
- return scanEscapeSequence(
13807
- /*shouldEmitInvalidEscapeError*/
13808
- unicodeMode,
13809
- /*isRegularExpression*/
13810
- annexB ? "annex-b" : true
13811
- );
13725
+ scanSourceCharacter();
13726
+ isPreviousTermQuantifiable = true;
13727
+ break;
13812
13728
  }
13813
13729
  }
13814
- function scanGroupName(isReference) {
13815
- Debug.assertEqual(text2.charCodeAt(pos - 1), 60 /* lessThan */);
13816
- tokenStart = pos;
13817
- scanIdentifier(codePointAt(text2, pos), languageVersion);
13818
- if (pos === tokenStart) {
13819
- error2(Diagnostics.Expected_a_capturing_group_name);
13820
- } else if (isReference) {
13821
- groupNameReferences.push({ pos: tokenStart, end: pos, name: tokenValue });
13822
- } else if (namedCapturingGroups.some((group2) => group2.has(tokenValue))) {
13823
- error2(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
13730
+ }
13731
+ function scanPatternModifiers(currFlags) {
13732
+ while (true) {
13733
+ const ch = charCodeChecked(pos);
13734
+ if (ch === -1 /* EOF */ || !isIdentifierPart(ch, languageVersion)) {
13735
+ break;
13736
+ }
13737
+ const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
13738
+ if (flag === void 0) {
13739
+ error2(Diagnostics.Unknown_regular_expression_flag, pos, 1);
13740
+ } else if (currFlags & flag) {
13741
+ error2(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
13742
+ } else if (!(flag & 28 /* Modifiers */)) {
13743
+ error2(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
13824
13744
  } else {
13825
- last(namedCapturingGroups).add(tokenValue);
13826
- groupSpecifiers.add(tokenValue);
13745
+ currFlags |= flag;
13746
+ checkRegularExpressionFlagAvailable(flag, pos);
13827
13747
  }
13748
+ pos++;
13828
13749
  }
13829
- function isClassContentExit(ch) {
13830
- return ch === 93 /* closeBracket */ || pos >= end2;
13750
+ return currFlags;
13751
+ }
13752
+ function scanAtomEscape() {
13753
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
13754
+ switch (charCodeChecked(pos)) {
13755
+ case 107 /* k */:
13756
+ pos++;
13757
+ if (charCodeChecked(pos) === 60 /* lessThan */) {
13758
+ pos++;
13759
+ scanGroupName(
13760
+ /*isReference*/
13761
+ true
13762
+ );
13763
+ scanExpectedChar(62 /* greaterThan */);
13764
+ } else if (unicodeMode) {
13765
+ error2(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
13766
+ }
13767
+ break;
13768
+ case 113 /* q */:
13769
+ if (unicodeSetsMode) {
13770
+ pos++;
13771
+ error2(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
13772
+ break;
13773
+ }
13774
+ default:
13775
+ Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
13776
+ /*atomEscape*/
13777
+ true
13778
+ ));
13779
+ break;
13831
13780
  }
13832
- function scanClassRanges() {
13833
- Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
13834
- if (text2.charCodeAt(pos) === 94 /* caret */) {
13781
+ }
13782
+ function scanDecimalEscape() {
13783
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
13784
+ const ch = charCodeChecked(pos);
13785
+ if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
13786
+ const start2 = pos;
13787
+ scanDigits();
13788
+ decimalEscapes = append(decimalEscapes, { pos: start2, end: pos, value: +tokenValue });
13789
+ return true;
13790
+ }
13791
+ return false;
13792
+ }
13793
+ function scanCharacterEscape(atomEscape) {
13794
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
13795
+ let ch = charCodeChecked(pos);
13796
+ switch (ch) {
13797
+ case 99 /* c */:
13835
13798
  pos++;
13799
+ ch = charCodeChecked(pos);
13800
+ if (isASCIILetter(ch)) {
13801
+ pos++;
13802
+ return String.fromCharCode(ch & 31);
13803
+ }
13804
+ if (unicodeMode) {
13805
+ error2(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
13806
+ } else if (atomEscape && annexB) {
13807
+ pos--;
13808
+ return "\\";
13809
+ }
13810
+ return String.fromCharCode(ch);
13811
+ case 94 /* caret */:
13812
+ case 36 /* $ */:
13813
+ case 47 /* slash */:
13814
+ case 92 /* backslash */:
13815
+ case 46 /* dot */:
13816
+ case 42 /* asterisk */:
13817
+ case 43 /* plus */:
13818
+ case 63 /* question */:
13819
+ case 40 /* openParen */:
13820
+ case 41 /* closeParen */:
13821
+ case 91 /* openBracket */:
13822
+ case 93 /* closeBracket */:
13823
+ case 123 /* openBrace */:
13824
+ case 125 /* closeBrace */:
13825
+ case 124 /* bar */:
13826
+ pos++;
13827
+ return String.fromCharCode(ch);
13828
+ default:
13829
+ if (pos >= end) {
13830
+ error2(Diagnostics.Undetermined_character_escape, pos - 1, 1);
13831
+ return "\\";
13832
+ }
13833
+ pos--;
13834
+ return scanEscapeSequence(
13835
+ /*shouldEmitInvalidEscapeError*/
13836
+ unicodeMode,
13837
+ /*isRegularExpression*/
13838
+ annexB ? "annex-b" : true
13839
+ );
13840
+ }
13841
+ }
13842
+ function scanGroupName(isReference) {
13843
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 60 /* lessThan */);
13844
+ tokenStart = pos;
13845
+ scanIdentifier(codePointChecked(pos), languageVersion);
13846
+ if (pos === tokenStart) {
13847
+ error2(Diagnostics.Expected_a_capturing_group_name);
13848
+ } else if (isReference) {
13849
+ groupNameReferences = append(groupNameReferences, { pos: tokenStart, end: pos, name: tokenValue });
13850
+ } else if ((topNamedCapturingGroupsScope == null ? void 0 : topNamedCapturingGroupsScope.has(tokenValue)) || namedCapturingGroupsScopeStack.some((group2) => group2 == null ? void 0 : group2.has(tokenValue))) {
13851
+ error2(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
13852
+ } else {
13853
+ topNamedCapturingGroupsScope ?? (topNamedCapturingGroupsScope = /* @__PURE__ */ new Set());
13854
+ topNamedCapturingGroupsScope.add(tokenValue);
13855
+ groupSpecifiers ?? (groupSpecifiers = /* @__PURE__ */ new Set());
13856
+ groupSpecifiers.add(tokenValue);
13857
+ }
13858
+ }
13859
+ function isClassContentExit(ch) {
13860
+ return ch === 93 /* closeBracket */ || ch === -1 /* EOF */ || pos >= end;
13861
+ }
13862
+ function scanClassRanges() {
13863
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 91 /* openBracket */);
13864
+ if (charCodeChecked(pos) === 94 /* caret */) {
13865
+ pos++;
13866
+ }
13867
+ while (true) {
13868
+ const ch = charCodeChecked(pos);
13869
+ if (isClassContentExit(ch)) {
13870
+ return;
13836
13871
  }
13837
- while (pos < end2) {
13838
- const ch = text2.charCodeAt(pos);
13839
- if (isClassContentExit(ch)) {
13872
+ const minStart = pos;
13873
+ const minCharacter = scanClassAtom();
13874
+ if (charCodeChecked(pos) === 45 /* minus */) {
13875
+ pos++;
13876
+ const ch2 = charCodeChecked(pos);
13877
+ if (isClassContentExit(ch2)) {
13840
13878
  return;
13841
13879
  }
13842
- const minStart = pos;
13843
- const minCharacter = scanClassAtom();
13844
- if (text2.charCodeAt(pos) === 45 /* minus */) {
13845
- pos++;
13846
- const ch2 = text2.charCodeAt(pos);
13847
- if (isClassContentExit(ch2)) {
13848
- return;
13880
+ if (!minCharacter && !annexB) {
13881
+ error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
13882
+ }
13883
+ const maxStart = pos;
13884
+ const maxCharacter = scanClassAtom();
13885
+ if (!maxCharacter && !annexB) {
13886
+ error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
13887
+ continue;
13888
+ }
13889
+ if (!minCharacter) {
13890
+ continue;
13891
+ }
13892
+ const minCharacterValue = codePointAt(minCharacter, 0);
13893
+ const maxCharacterValue = codePointAt(maxCharacter, 0);
13894
+ if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
13895
+ error2(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
13896
+ }
13897
+ }
13898
+ }
13899
+ }
13900
+ function scanClassSetExpression() {
13901
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 91 /* openBracket */);
13902
+ let isCharacterComplement = false;
13903
+ if (charCodeChecked(pos) === 94 /* caret */) {
13904
+ pos++;
13905
+ isCharacterComplement = true;
13906
+ }
13907
+ let expressionMayContainStrings = false;
13908
+ let ch = charCodeChecked(pos);
13909
+ if (isClassContentExit(ch)) {
13910
+ return;
13911
+ }
13912
+ let start2 = pos;
13913
+ let operand;
13914
+ switch (text.slice(pos, pos + 2)) {
13915
+ case "--":
13916
+ case "&&":
13917
+ error2(Diagnostics.Expected_a_class_set_operand);
13918
+ mayContainStrings = false;
13919
+ break;
13920
+ default:
13921
+ operand = scanClassSetOperand();
13922
+ break;
13923
+ }
13924
+ switch (charCodeChecked(pos)) {
13925
+ case 45 /* minus */:
13926
+ if (charCodeChecked(pos + 1) === 45 /* minus */) {
13927
+ if (isCharacterComplement && mayContainStrings) {
13928
+ error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
13849
13929
  }
13850
- if (!minCharacter && !annexB) {
13851
- error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
13930
+ expressionMayContainStrings = mayContainStrings;
13931
+ scanClassSetSubExpression(3 /* ClassSubtraction */);
13932
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
13933
+ return;
13934
+ }
13935
+ break;
13936
+ case 38 /* ampersand */:
13937
+ if (charCodeChecked(pos + 1) === 38 /* ampersand */) {
13938
+ scanClassSetSubExpression(2 /* ClassIntersection */);
13939
+ if (isCharacterComplement && mayContainStrings) {
13940
+ error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
13852
13941
  }
13853
- const maxStart = pos;
13854
- const maxCharacter = scanClassAtom();
13855
- if (!maxCharacter && !annexB) {
13856
- error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
13857
- continue;
13942
+ expressionMayContainStrings = mayContainStrings;
13943
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
13944
+ return;
13945
+ } else {
13946
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
13947
+ }
13948
+ break;
13949
+ default:
13950
+ if (isCharacterComplement && mayContainStrings) {
13951
+ error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
13952
+ }
13953
+ expressionMayContainStrings = mayContainStrings;
13954
+ break;
13955
+ }
13956
+ while (true) {
13957
+ ch = charCodeChecked(pos);
13958
+ if (ch === -1 /* EOF */) {
13959
+ break;
13960
+ }
13961
+ switch (ch) {
13962
+ case 45 /* minus */:
13963
+ pos++;
13964
+ ch = charCodeChecked(pos);
13965
+ if (isClassContentExit(ch)) {
13966
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
13967
+ return;
13858
13968
  }
13859
- if (!minCharacter) {
13969
+ if (ch === 45 /* minus */) {
13970
+ pos++;
13971
+ error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
13972
+ start2 = pos - 2;
13973
+ operand = text.slice(start2, pos);
13860
13974
  continue;
13975
+ } else {
13976
+ if (!operand) {
13977
+ error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
13978
+ }
13979
+ const secondStart = pos;
13980
+ const secondOperand = scanClassSetOperand();
13981
+ if (isCharacterComplement && mayContainStrings) {
13982
+ error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
13983
+ }
13984
+ expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
13985
+ if (!secondOperand) {
13986
+ error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
13987
+ break;
13988
+ }
13989
+ if (!operand) {
13990
+ break;
13991
+ }
13992
+ const minCharacterValue = codePointAt(operand, 0);
13993
+ const maxCharacterValue = codePointAt(secondOperand, 0);
13994
+ if (operand.length === charSize(minCharacterValue) && secondOperand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
13995
+ error2(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
13996
+ }
13861
13997
  }
13862
- const minCharacterValue = codePointAt(minCharacter, 0);
13863
- const maxCharacterValue = codePointAt(maxCharacter, 0);
13864
- if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
13865
- error2(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
13998
+ break;
13999
+ case 38 /* ampersand */:
14000
+ start2 = pos;
14001
+ pos++;
14002
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
14003
+ pos++;
14004
+ error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
14005
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
14006
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
14007
+ pos++;
14008
+ }
14009
+ } else {
14010
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
13866
14011
  }
13867
- }
13868
- }
13869
- }
13870
- function scanClassSetExpression() {
13871
- Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
13872
- let isCharacterComplement = false;
13873
- if (text2.charCodeAt(pos) === 94 /* caret */) {
13874
- pos++;
13875
- isCharacterComplement = true;
14012
+ operand = text.slice(start2, pos);
14013
+ continue;
13876
14014
  }
13877
- let expressionMayContainStrings = false;
13878
- let ch = text2.charCodeAt(pos);
13879
- if (isClassContentExit(ch)) {
13880
- return;
14015
+ if (isClassContentExit(charCodeChecked(pos))) {
14016
+ break;
13881
14017
  }
13882
- let start2 = pos;
13883
- let oprand;
13884
- switch (text2.slice(pos, pos + 2)) {
14018
+ start2 = pos;
14019
+ switch (text.slice(pos, pos + 2)) {
13885
14020
  case "--":
13886
14021
  case "&&":
13887
- error2(Diagnostics.Expected_a_class_set_oprand);
13888
- mayContainStrings = false;
14022
+ error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
14023
+ pos += 2;
14024
+ operand = text.slice(start2, pos);
13889
14025
  break;
13890
14026
  default:
13891
- oprand = scanClassSetOprand();
14027
+ operand = scanClassSetOperand();
13892
14028
  break;
13893
14029
  }
13894
- switch (text2.charCodeAt(pos)) {
14030
+ }
14031
+ mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
14032
+ }
14033
+ function scanClassSetSubExpression(expressionType) {
14034
+ let expressionMayContainStrings = mayContainStrings;
14035
+ while (true) {
14036
+ let ch = charCodeChecked(pos);
14037
+ if (isClassContentExit(ch)) {
14038
+ break;
14039
+ }
14040
+ switch (ch) {
13895
14041
  case 45 /* minus */:
13896
- if (text2.charCodeAt(pos + 1) === 45 /* minus */) {
13897
- if (isCharacterComplement && mayContainStrings) {
13898
- error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
14042
+ pos++;
14043
+ if (charCodeChecked(pos) === 45 /* minus */) {
14044
+ pos++;
14045
+ if (expressionType !== 3 /* ClassSubtraction */) {
14046
+ error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
13899
14047
  }
13900
- expressionMayContainStrings = mayContainStrings;
13901
- scanClassSetSubExpression(3 /* ClassSubtraction */);
13902
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
13903
- return;
14048
+ } else {
14049
+ error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
13904
14050
  }
13905
14051
  break;
13906
14052
  case 38 /* ampersand */:
13907
- if (text2.charCodeAt(pos + 1) === 38 /* ampersand */) {
13908
- scanClassSetSubExpression(2 /* ClassIntersection */);
13909
- if (isCharacterComplement && mayContainStrings) {
13910
- error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
14053
+ pos++;
14054
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
14055
+ pos++;
14056
+ if (expressionType !== 2 /* ClassIntersection */) {
14057
+ error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
14058
+ }
14059
+ if (charCodeChecked(pos) === 38 /* ampersand */) {
14060
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
14061
+ pos++;
13911
14062
  }
13912
- expressionMayContainStrings = mayContainStrings;
13913
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
13914
- return;
13915
14063
  } else {
13916
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
14064
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
13917
14065
  }
13918
14066
  break;
13919
14067
  default:
13920
- if (isCharacterComplement && mayContainStrings) {
13921
- error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
14068
+ switch (expressionType) {
14069
+ case 3 /* ClassSubtraction */:
14070
+ error2(Diagnostics._0_expected, pos, 0, "--");
14071
+ break;
14072
+ case 2 /* ClassIntersection */:
14073
+ error2(Diagnostics._0_expected, pos, 0, "&&");
14074
+ break;
14075
+ default:
14076
+ break;
13922
14077
  }
13923
- expressionMayContainStrings = mayContainStrings;
13924
14078
  break;
13925
14079
  }
13926
- while (pos < end2) {
13927
- ch = text2.charCodeAt(pos);
13928
- switch (ch) {
13929
- case 45 /* minus */:
13930
- pos++;
13931
- ch = text2.charCodeAt(pos);
13932
- if (isClassContentExit(ch)) {
13933
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
13934
- return;
13935
- }
13936
- if (ch === 45 /* minus */) {
13937
- pos++;
13938
- error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
13939
- start2 = pos - 2;
13940
- oprand = text2.slice(start2, pos);
13941
- continue;
13942
- } else {
13943
- if (!oprand) {
13944
- error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
13945
- }
13946
- const secondStart = pos;
13947
- const secondOprand = scanClassSetOprand();
13948
- if (isCharacterComplement && mayContainStrings) {
13949
- error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
13950
- }
13951
- expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
13952
- if (!secondOprand) {
13953
- error2(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
13954
- break;
13955
- }
13956
- if (!oprand) {
13957
- break;
13958
- }
13959
- const minCharacterValue = codePointAt(oprand, 0);
13960
- const maxCharacterValue = codePointAt(secondOprand, 0);
13961
- if (oprand.length === charSize(minCharacterValue) && secondOprand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
13962
- error2(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
13963
- }
13964
- }
13965
- break;
13966
- case 38 /* ampersand */:
13967
- start2 = pos;
13968
- pos++;
13969
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
13970
- pos++;
13971
- error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
13972
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
13973
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
13974
- pos++;
13975
- }
13976
- } else {
13977
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
13978
- }
13979
- oprand = text2.slice(start2, pos);
13980
- continue;
13981
- }
13982
- if (isClassContentExit(text2.charCodeAt(pos))) {
13983
- break;
13984
- }
13985
- start2 = pos;
13986
- switch (text2.slice(pos, pos + 2)) {
13987
- case "--":
13988
- case "&&":
13989
- error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
13990
- pos += 2;
13991
- oprand = text2.slice(start2, pos);
13992
- break;
13993
- default:
13994
- oprand = scanClassSetOprand();
13995
- break;
13996
- }
14080
+ ch = charCodeChecked(pos);
14081
+ if (isClassContentExit(ch)) {
14082
+ error2(Diagnostics.Expected_a_class_set_operand);
14083
+ break;
13997
14084
  }
13998
- mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
14085
+ scanClassSetOperand();
14086
+ expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
13999
14087
  }
14000
- function scanClassSetSubExpression(expressionType) {
14001
- let expressionMayContainStrings = mayContainStrings;
14002
- while (pos < end2) {
14003
- let ch = text2.charCodeAt(pos);
14004
- if (isClassContentExit(ch)) {
14005
- break;
14006
- }
14007
- switch (ch) {
14008
- case 45 /* minus */:
14009
- pos++;
14010
- if (text2.charCodeAt(pos) === 45 /* minus */) {
14011
- pos++;
14012
- if (expressionType !== 3 /* ClassSubtraction */) {
14013
- error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
14014
- }
14015
- } else {
14016
- error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
14017
- }
14018
- break;
14019
- case 38 /* ampersand */:
14088
+ mayContainStrings = expressionMayContainStrings;
14089
+ }
14090
+ function scanClassSetOperand() {
14091
+ mayContainStrings = false;
14092
+ switch (charCodeChecked(pos)) {
14093
+ case -1 /* EOF */:
14094
+ return "";
14095
+ case 91 /* openBracket */:
14096
+ pos++;
14097
+ scanClassSetExpression();
14098
+ scanExpectedChar(93 /* closeBracket */);
14099
+ return "";
14100
+ case 92 /* backslash */:
14101
+ pos++;
14102
+ if (scanCharacterClassEscape()) {
14103
+ return "";
14104
+ } else if (charCodeChecked(pos) === 113 /* q */) {
14105
+ pos++;
14106
+ if (charCodeChecked(pos) === 123 /* openBrace */) {
14020
14107
  pos++;
14021
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
14022
- pos++;
14023
- if (expressionType !== 2 /* ClassIntersection */) {
14024
- error2(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
14025
- }
14026
- if (text2.charCodeAt(pos) === 38 /* ampersand */) {
14027
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
14028
- pos++;
14029
- }
14030
- } else {
14031
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
14032
- }
14033
- break;
14034
- default:
14035
- switch (expressionType) {
14036
- case 3 /* ClassSubtraction */:
14037
- error2(Diagnostics._0_expected, pos, 0, "--");
14038
- break;
14039
- case 2 /* ClassIntersection */:
14040
- error2(Diagnostics._0_expected, pos, 0, "&&");
14041
- break;
14042
- default:
14043
- break;
14044
- }
14045
- break;
14108
+ scanClassStringDisjunctionContents();
14109
+ scanExpectedChar(125 /* closeBrace */);
14110
+ return "";
14111
+ } else {
14112
+ error2(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
14113
+ return "q";
14114
+ }
14046
14115
  }
14047
- ch = text2.charCodeAt(pos);
14048
- if (isClassContentExit(ch)) {
14049
- error2(Diagnostics.Expected_a_class_set_oprand);
14116
+ pos--;
14117
+ default:
14118
+ return scanClassSetCharacter();
14119
+ }
14120
+ }
14121
+ function scanClassStringDisjunctionContents() {
14122
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 123 /* openBrace */);
14123
+ let characterCount = 0;
14124
+ while (true) {
14125
+ const ch = charCodeChecked(pos);
14126
+ switch (ch) {
14127
+ case -1 /* EOF */:
14128
+ return;
14129
+ case 125 /* closeBrace */:
14130
+ if (characterCount !== 1) {
14131
+ mayContainStrings = true;
14132
+ }
14133
+ return;
14134
+ case 124 /* bar */:
14135
+ if (characterCount !== 1) {
14136
+ mayContainStrings = true;
14137
+ }
14138
+ pos++;
14139
+ start = pos;
14140
+ characterCount = 0;
14141
+ break;
14142
+ default:
14143
+ scanClassSetCharacter();
14144
+ characterCount++;
14050
14145
  break;
14051
- }
14052
- scanClassSetOprand();
14053
- expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
14054
14146
  }
14055
- mayContainStrings = expressionMayContainStrings;
14056
14147
  }
14057
- function scanClassSetOprand() {
14058
- mayContainStrings = false;
14059
- switch (text2.charCodeAt(pos)) {
14060
- case 91 /* openBracket */:
14148
+ }
14149
+ function scanClassSetCharacter() {
14150
+ const ch = charCodeChecked(pos);
14151
+ if (ch === -1 /* EOF */) {
14152
+ return "";
14153
+ }
14154
+ if (ch === 92 /* backslash */) {
14155
+ pos++;
14156
+ const ch2 = charCodeChecked(pos);
14157
+ switch (ch2) {
14158
+ case 98 /* b */:
14061
14159
  pos++;
14062
- scanClassSetExpression();
14063
- scanExpectedChar(93 /* closeBracket */);
14064
- return "";
14065
- case 92 /* backslash */:
14160
+ return "\b";
14161
+ case 38 /* ampersand */:
14162
+ case 45 /* minus */:
14163
+ case 33 /* exclamation */:
14164
+ case 35 /* hash */:
14165
+ case 37 /* percent */:
14166
+ case 44 /* comma */:
14167
+ case 58 /* colon */:
14168
+ case 59 /* semicolon */:
14169
+ case 60 /* lessThan */:
14170
+ case 61 /* equals */:
14171
+ case 62 /* greaterThan */:
14172
+ case 64 /* at */:
14173
+ case 96 /* backtick */:
14174
+ case 126 /* tilde */:
14066
14175
  pos++;
14067
- if (scanCharacterClassEscape()) {
14068
- return "";
14069
- } else if (text2.charCodeAt(pos) === 113 /* q */) {
14070
- pos++;
14071
- if (text2.charCodeAt(pos) === 123 /* openBrace */) {
14072
- pos++;
14073
- scanClassStringDisjunctionContents();
14074
- scanExpectedChar(125 /* closeBrace */);
14075
- return "";
14076
- } else {
14077
- error2(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
14078
- return "q";
14079
- }
14080
- }
14081
- pos--;
14176
+ return String.fromCharCode(ch2);
14082
14177
  default:
14083
- return scanClassSetCharacter();
14084
- }
14085
- }
14086
- function scanClassStringDisjunctionContents() {
14087
- Debug.assertEqual(text2.charCodeAt(pos - 1), 123 /* openBrace */);
14088
- let characterCount = 0;
14089
- while (pos < end2) {
14090
- const ch = text2.charCodeAt(pos);
14091
- switch (ch) {
14092
- case 125 /* closeBrace */:
14093
- if (characterCount !== 1) {
14094
- mayContainStrings = true;
14095
- }
14096
- return;
14097
- case 124 /* bar */:
14098
- if (characterCount !== 1) {
14099
- mayContainStrings = true;
14100
- }
14101
- pos++;
14102
- start = pos;
14103
- characterCount = 0;
14104
- break;
14105
- default:
14106
- scanClassSetCharacter();
14107
- characterCount++;
14108
- break;
14109
- }
14178
+ return scanCharacterEscape(
14179
+ /*atomEscape*/
14180
+ false
14181
+ );
14182
+ }
14183
+ } else if (ch === charCodeChecked(pos + 1)) {
14184
+ switch (ch) {
14185
+ case 38 /* ampersand */:
14186
+ case 33 /* exclamation */:
14187
+ case 35 /* hash */:
14188
+ case 37 /* percent */:
14189
+ case 42 /* asterisk */:
14190
+ case 43 /* plus */:
14191
+ case 44 /* comma */:
14192
+ case 46 /* dot */:
14193
+ case 58 /* colon */:
14194
+ case 59 /* semicolon */:
14195
+ case 60 /* lessThan */:
14196
+ case 61 /* equals */:
14197
+ case 62 /* greaterThan */:
14198
+ case 63 /* question */:
14199
+ case 64 /* at */:
14200
+ case 96 /* backtick */:
14201
+ case 126 /* tilde */:
14202
+ error2(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
14203
+ pos += 2;
14204
+ return text.substring(pos - 2, pos);
14110
14205
  }
14111
14206
  }
14112
- function scanClassSetCharacter() {
14113
- const ch = text2.charCodeAt(pos);
14114
- if (ch === 92 /* backslash */) {
14207
+ switch (ch) {
14208
+ case 47 /* slash */:
14209
+ case 40 /* openParen */:
14210
+ case 41 /* closeParen */:
14211
+ case 91 /* openBracket */:
14212
+ case 93 /* closeBracket */:
14213
+ case 123 /* openBrace */:
14214
+ case 125 /* closeBrace */:
14215
+ case 45 /* minus */:
14216
+ case 124 /* bar */:
14217
+ error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
14115
14218
  pos++;
14116
- const ch2 = text2.charCodeAt(pos);
14117
- switch (ch2) {
14118
- case 98 /* b */:
14119
- pos++;
14120
- return "\b";
14121
- case 38 /* ampersand */:
14122
- case 45 /* minus */:
14123
- case 33 /* exclamation */:
14124
- case 35 /* hash */:
14125
- case 37 /* percent */:
14126
- case 44 /* comma */:
14127
- case 58 /* colon */:
14128
- case 59 /* semicolon */:
14129
- case 60 /* lessThan */:
14130
- case 61 /* equals */:
14131
- case 62 /* greaterThan */:
14132
- case 64 /* at */:
14133
- case 96 /* backtick */:
14134
- case 126 /* tilde */:
14135
- pos++;
14136
- return String.fromCharCode(ch2);
14137
- default:
14138
- return scanCharacterEscape(
14139
- /*atomEscape*/
14140
- false
14141
- );
14142
- }
14143
- } else if (ch === text2.charCodeAt(pos + 1)) {
14144
- switch (ch) {
14145
- case 38 /* ampersand */:
14146
- case 33 /* exclamation */:
14147
- case 35 /* hash */:
14148
- case 37 /* percent */:
14149
- case 42 /* asterisk */:
14150
- case 43 /* plus */:
14151
- case 44 /* comma */:
14152
- case 46 /* dot */:
14153
- case 58 /* colon */:
14154
- case 59 /* semicolon */:
14155
- case 60 /* lessThan */:
14156
- case 61 /* equals */:
14157
- case 62 /* greaterThan */:
14158
- case 63 /* question */:
14159
- case 64 /* at */:
14160
- case 96 /* backtick */:
14161
- case 126 /* tilde */:
14162
- error2(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
14163
- pos += 2;
14164
- return text2.substring(pos - 2, pos);
14165
- }
14166
- }
14219
+ return String.fromCharCode(ch);
14220
+ }
14221
+ return scanSourceCharacter();
14222
+ }
14223
+ function scanClassAtom() {
14224
+ if (charCodeChecked(pos) === 92 /* backslash */) {
14225
+ pos++;
14226
+ const ch = charCodeChecked(pos);
14167
14227
  switch (ch) {
14168
- case 47 /* slash */:
14169
- case 40 /* openParen */:
14170
- case 41 /* closeParen */:
14171
- case 91 /* openBracket */:
14172
- case 93 /* closeBracket */:
14173
- case 123 /* openBrace */:
14174
- case 125 /* closeBrace */:
14228
+ case 98 /* b */:
14229
+ pos++;
14230
+ return "\b";
14175
14231
  case 45 /* minus */:
14176
- case 124 /* bar */:
14177
- error2(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
14178
14232
  pos++;
14179
14233
  return String.fromCharCode(ch);
14234
+ default:
14235
+ if (scanCharacterClassEscape()) {
14236
+ return "";
14237
+ }
14238
+ return scanCharacterEscape(
14239
+ /*atomEscape*/
14240
+ false
14241
+ );
14180
14242
  }
14243
+ } else {
14181
14244
  return scanSourceCharacter();
14182
14245
  }
14183
- function scanClassAtom() {
14184
- if (text2.charCodeAt(pos) === 92 /* backslash */) {
14246
+ }
14247
+ function scanCharacterClassEscape() {
14248
+ Debug.assertEqual(charCodeUnchecked(pos - 1), 92 /* backslash */);
14249
+ let isCharacterComplement = false;
14250
+ const start2 = pos - 1;
14251
+ const ch = charCodeChecked(pos);
14252
+ switch (ch) {
14253
+ case 100 /* d */:
14254
+ case 68 /* D */:
14255
+ case 115 /* s */:
14256
+ case 83 /* S */:
14257
+ case 119 /* w */:
14258
+ case 87 /* W */:
14185
14259
  pos++;
14186
- const ch = text2.charCodeAt(pos);
14187
- switch (ch) {
14188
- case 98 /* b */:
14189
- pos++;
14190
- return "\b";
14191
- case 45 /* minus */:
14192
- pos++;
14193
- return String.fromCharCode(ch);
14194
- default:
14195
- if (scanCharacterClassEscape()) {
14196
- return "";
14197
- }
14198
- return scanCharacterEscape(
14199
- /*atomEscape*/
14200
- false
14201
- );
14202
- }
14203
- } else {
14204
- return scanSourceCharacter();
14205
- }
14206
- }
14207
- function scanCharacterClassEscape() {
14208
- Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
14209
- let isCharacterComplement = false;
14210
- const start2 = pos - 1;
14211
- const ch = text2.charCodeAt(pos);
14212
- switch (ch) {
14213
- case 100 /* d */:
14214
- case 68 /* D */:
14215
- case 115 /* s */:
14216
- case 83 /* S */:
14217
- case 119 /* w */:
14218
- case 87 /* W */:
14219
- pos++;
14220
- return true;
14221
- case 80 /* P */:
14222
- isCharacterComplement = true;
14223
- case 112 /* p */:
14260
+ return true;
14261
+ case 80 /* P */:
14262
+ isCharacterComplement = true;
14263
+ case 112 /* p */:
14264
+ pos++;
14265
+ if (charCodeChecked(pos) === 123 /* openBrace */) {
14224
14266
  pos++;
14225
- if (text2.charCodeAt(pos) === 123 /* openBrace */) {
14267
+ const propertyNameOrValueStart = pos;
14268
+ const propertyNameOrValue = scanWordCharacters();
14269
+ if (charCodeChecked(pos) === 61 /* equals */) {
14270
+ const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
14271
+ if (pos === propertyNameOrValueStart) {
14272
+ error2(Diagnostics.Expected_a_Unicode_property_name);
14273
+ } else if (propertyName === void 0) {
14274
+ error2(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
14275
+ const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
14276
+ if (suggestion) {
14277
+ error2(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
14278
+ }
14279
+ }
14226
14280
  pos++;
14227
- const propertyNameOrValueStart = pos;
14228
- const propertyNameOrValue = scanWordCharacters();
14229
- if (text2.charCodeAt(pos) === 61 /* equals */) {
14230
- const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
14231
- if (pos === propertyNameOrValueStart) {
14232
- error2(Diagnostics.Expected_a_Unicode_property_name);
14233
- } else if (propertyName === void 0) {
14234
- error2(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
14235
- const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
14236
- if (suggestion) {
14237
- error2(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
14238
- }
14281
+ const propertyValueStart = pos;
14282
+ const propertyValue = scanWordCharacters();
14283
+ if (pos === propertyValueStart) {
14284
+ error2(Diagnostics.Expected_a_Unicode_property_value);
14285
+ } else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
14286
+ error2(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
14287
+ const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
14288
+ if (suggestion) {
14289
+ error2(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
14239
14290
  }
14240
- pos++;
14241
- const propertyValueStart = pos;
14242
- const propertyValue = scanWordCharacters();
14243
- if (pos === propertyValueStart) {
14244
- error2(Diagnostics.Expected_a_Unicode_property_value);
14245
- } else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
14246
- error2(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
14247
- const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
14248
- if (suggestion) {
14249
- error2(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
14250
- }
14291
+ }
14292
+ } else {
14293
+ if (pos === propertyNameOrValueStart) {
14294
+ error2(Diagnostics.Expected_a_Unicode_property_name_or_value);
14295
+ } else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
14296
+ if (!unicodeSetsMode) {
14297
+ error2(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);
14298
+ } else if (isCharacterComplement) {
14299
+ error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
14300
+ } else {
14301
+ mayContainStrings = true;
14251
14302
  }
14252
- } else {
14253
- if (pos === propertyNameOrValueStart) {
14254
- error2(Diagnostics.Expected_a_Unicode_property_name_or_value);
14255
- } else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
14256
- if (!unicodeSetsMode) {
14257
- error2(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);
14258
- } else if (isCharacterComplement) {
14259
- error2(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
14260
- } else {
14261
- mayContainStrings = true;
14262
- }
14263
- } else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
14264
- error2(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
14265
- const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
14266
- if (suggestion) {
14267
- error2(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
14268
- }
14303
+ } else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
14304
+ error2(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
14305
+ const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
14306
+ if (suggestion) {
14307
+ error2(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
14269
14308
  }
14270
14309
  }
14271
- scanExpectedChar(125 /* closeBrace */);
14272
- if (!unicodeMode) {
14273
- error2(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
14274
- }
14275
- } else if (unicodeMode) {
14276
- error2(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
14277
14310
  }
14278
- return true;
14279
- }
14280
- return false;
14281
- }
14282
- function scanWordCharacters() {
14283
- let value = "";
14284
- while (pos < end2) {
14285
- const ch = text2.charCodeAt(pos);
14286
- if (!isWordCharacter(ch)) {
14287
- break;
14311
+ scanExpectedChar(125 /* closeBrace */);
14312
+ if (!unicodeMode) {
14313
+ error2(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
14314
+ }
14315
+ } else if (unicodeMode) {
14316
+ error2(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
14288
14317
  }
14289
- value += String.fromCharCode(ch);
14290
- pos++;
14318
+ return true;
14319
+ }
14320
+ return false;
14321
+ }
14322
+ function scanWordCharacters() {
14323
+ let value = "";
14324
+ while (true) {
14325
+ const ch = charCodeChecked(pos);
14326
+ if (ch === -1 /* EOF */ || !isWordCharacter(ch)) {
14327
+ break;
14291
14328
  }
14292
- return value;
14329
+ value += String.fromCharCode(ch);
14330
+ pos++;
14331
+ }
14332
+ return value;
14333
+ }
14334
+ function scanSourceCharacter() {
14335
+ const size = unicodeMode ? charSize(charCodeChecked(pos)) : 1;
14336
+ pos += size;
14337
+ return size > 0 ? text.substring(pos - size, pos) : "";
14338
+ }
14339
+ function scanExpectedChar(ch) {
14340
+ if (charCodeChecked(pos) === ch) {
14341
+ pos++;
14342
+ } else {
14343
+ error2(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
14293
14344
  }
14294
- function scanSourceCharacter() {
14295
- const size = unicodeMode ? charSize(codePointAt(text2, pos)) : 1;
14296
- pos += size;
14297
- return text2.substring(pos - size, pos);
14345
+ }
14346
+ scanDisjunction(
14347
+ /*isInGroup*/
14348
+ false
14349
+ );
14350
+ forEach(groupNameReferences, (reference) => {
14351
+ if (!(groupSpecifiers == null ? void 0 : groupSpecifiers.has(reference.name))) {
14352
+ error2(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
14298
14353
  }
14299
- function scanExpectedChar(ch) {
14300
- if (text2.charCodeAt(pos) === ch) {
14301
- pos++;
14354
+ });
14355
+ forEach(decimalEscapes, (escape) => {
14356
+ if (!annexB && escape.value > numberOfCapturingGroups) {
14357
+ if (numberOfCapturingGroups) {
14358
+ error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
14302
14359
  } else {
14303
- error2(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
14360
+ error2(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
14304
14361
  }
14305
14362
  }
14306
- scanDisjunction(
14307
- /*isInGroup*/
14308
- false
14309
- );
14310
- forEach(groupNameReferences, (reference) => {
14311
- if (!groupSpecifiers.has(reference.name)) {
14312
- error2(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
14313
- }
14314
- });
14315
- forEach(decimalEscapes, (escape) => {
14316
- if (!annexB && escape.value > numberOfCapturingGroups) {
14317
- if (numberOfCapturingGroups) {
14318
- error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
14319
- } else {
14320
- error2(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
14321
- }
14322
- }
14323
- });
14324
- }
14325
- function checkRegularExpressionFlagAvailable(flag, pos2) {
14326
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
14327
- if (availableFrom && languageVersion < availableFrom) {
14328
- error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
14329
- }
14363
+ });
14364
+ }
14365
+ function checkRegularExpressionFlagAvailable(flag, pos2) {
14366
+ const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
14367
+ if (availableFrom && languageVersion < availableFrom) {
14368
+ error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
14330
14369
  }
14331
14370
  }
14332
14371
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
@@ -14394,9 +14433,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14394
14433
  if (pos >= end) {
14395
14434
  return token = 1 /* EndOfFileToken */;
14396
14435
  }
14397
- let char = text.charCodeAt(pos);
14436
+ let char = charCodeUnchecked(pos);
14398
14437
  if (char === 60 /* lessThan */) {
14399
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
14438
+ if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
14400
14439
  pos += 2;
14401
14440
  return token = 31 /* LessThanSlashToken */;
14402
14441
  }
@@ -14409,7 +14448,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14409
14448
  }
14410
14449
  let firstNonWhitespace = 0;
14411
14450
  while (pos < end) {
14412
- char = text.charCodeAt(pos);
14451
+ char = charCodeUnchecked(pos);
14413
14452
  if (char === 123 /* openBrace */) {
14414
14453
  break;
14415
14454
  }
@@ -14441,7 +14480,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14441
14480
  function scanJsxIdentifier() {
14442
14481
  if (tokenIsIdentifierOrKeyword(token)) {
14443
14482
  while (pos < end) {
14444
- const ch = text.charCodeAt(pos);
14483
+ const ch = charCodeUnchecked(pos);
14445
14484
  if (ch === 45 /* minus */) {
14446
14485
  tokenValue += "-";
14447
14486
  pos++;
@@ -14459,7 +14498,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14459
14498
  }
14460
14499
  function scanJsxAttributeValue() {
14461
14500
  fullStartPos = pos;
14462
- switch (text.charCodeAt(pos)) {
14501
+ switch (charCodeUnchecked(pos)) {
14463
14502
  case 34 /* doubleQuote */:
14464
14503
  case 39 /* singleQuote */:
14465
14504
  tokenValue = scanString(
@@ -14481,11 +14520,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14481
14520
  if (pos >= end) {
14482
14521
  return token = 1 /* EndOfFileToken */;
14483
14522
  }
14484
- for (let ch = text.charCodeAt(pos); pos < end && (!isLineBreak(ch) && ch !== 96 /* backtick */); ch = codePointAt(text, ++pos)) {
14523
+ for (let ch = charCodeUnchecked(pos); pos < end && (!isLineBreak(ch) && ch !== 96 /* backtick */); ch = codePointUnchecked(++pos)) {
14485
14524
  if (!inBackticks) {
14486
14525
  if (ch === 123 /* openBrace */) {
14487
14526
  break;
14488
- } else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(text.charCodeAt(pos - 1)) && !(pos + 1 < end && isWhiteSpaceLike(text.charCodeAt(pos + 1)))) {
14527
+ } else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(charCodeUnchecked(pos - 1)) && !(pos + 1 < end && isWhiteSpaceLike(charCodeUnchecked(pos + 1)))) {
14489
14528
  break;
14490
14529
  }
14491
14530
  }
@@ -14502,21 +14541,21 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14502
14541
  if (pos >= end) {
14503
14542
  return token = 1 /* EndOfFileToken */;
14504
14543
  }
14505
- const ch = codePointAt(text, pos);
14544
+ const ch = codePointUnchecked(pos);
14506
14545
  pos += charSize(ch);
14507
14546
  switch (ch) {
14508
14547
  case 9 /* tab */:
14509
14548
  case 11 /* verticalTab */:
14510
14549
  case 12 /* formFeed */:
14511
14550
  case 32 /* space */:
14512
- while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
14551
+ while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
14513
14552
  pos++;
14514
14553
  }
14515
14554
  return token = 5 /* WhitespaceTrivia */;
14516
14555
  case 64 /* at */:
14517
14556
  return token = 60 /* AtToken */;
14518
14557
  case 13 /* carriageReturn */:
14519
- if (text.charCodeAt(pos) === 10 /* lineFeed */) {
14558
+ if (charCodeUnchecked(pos) === 10 /* lineFeed */) {
14520
14559
  pos++;
14521
14560
  }
14522
14561
  case 10 /* lineFeed */:
@@ -14572,7 +14611,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14572
14611
  }
14573
14612
  if (isIdentifierStart(ch, languageVersion)) {
14574
14613
  let char = ch;
14575
- while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */)
14614
+ while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === 45 /* minus */)
14576
14615
  pos += charSize(char);
14577
14616
  tokenValue = text.substring(tokenStart, pos);
14578
14617
  if (char === 92 /* backslash */) {
@@ -14682,6 +14721,9 @@ function charSize(ch) {
14682
14721
  if (ch >= 65536) {
14683
14722
  return 2;
14684
14723
  }
14724
+ if (ch === -1 /* EOF */) {
14725
+ return 0;
14726
+ }
14685
14727
  return 1;
14686
14728
  }
14687
14729
  function utf16EncodeAsStringFallback(codePoint) {
@@ -17460,7 +17502,8 @@ function createFileDiagnosticFromMessageChain(file, start, length2, messageChain
17460
17502
  code: messageChain.code,
17461
17503
  category: messageChain.category,
17462
17504
  messageText: messageChain.next ? messageChain : messageChain.messageText,
17463
- relatedInformation
17505
+ relatedInformation,
17506
+ canonicalHead: messageChain.canonicalHead
17464
17507
  };
17465
17508
  }
17466
17509
  function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) {
@@ -17492,6 +17535,12 @@ function createDiagnosticForRange(sourceFile, range, message) {
17492
17535
  messageText: message.message
17493
17536
  };
17494
17537
  }
17538
+ function getCanonicalDiagnostic(message, ...args) {
17539
+ return {
17540
+ code: message.code,
17541
+ messageText: formatMessage(message, ...args)
17542
+ };
17543
+ }
17495
17544
  function getSpanOfTokenAtPosition(sourceFile, pos) {
17496
17545
  const scanner2 = createScanner(
17497
17546
  sourceFile.languageVersion,
@@ -21625,7 +21674,9 @@ function compareDiagnostics(d1, d2) {
21625
21674
  return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */;
21626
21675
  }
21627
21676
  function compareDiagnosticsSkipRelatedInformation(d1, d2) {
21628
- 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 */;
21677
+ const code1 = getDiagnosticCode(d1);
21678
+ const code2 = getDiagnosticCode(d2);
21679
+ return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || compareValues(code1, code2) || compareMessageText(d1, d2) || 0 /* EqualTo */;
21629
21680
  }
21630
21681
  function compareRelatedInformation(d1, d2) {
21631
21682
  if (!d1.relatedInformation && !d2.relatedInformation) {
@@ -21639,21 +21690,32 @@ function compareRelatedInformation(d1, d2) {
21639
21690
  }
21640
21691
  return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */;
21641
21692
  }
21642
- function compareMessageText(t1, t2) {
21643
- if (typeof t1 === "string" && typeof t2 === "string") {
21644
- return compareStringsCaseSensitive(t1, t2);
21693
+ function compareMessageText(d1, d2) {
21694
+ let headMsg1 = getDiagnosticMessage(d1);
21695
+ let headMsg2 = getDiagnosticMessage(d2);
21696
+ if (typeof headMsg1 !== "string") {
21697
+ headMsg1 = headMsg1.messageText;
21645
21698
  }
21646
- if (typeof t1 === "string") {
21647
- t1 = { messageText: t1 };
21699
+ if (typeof headMsg2 !== "string") {
21700
+ headMsg2 = headMsg2.messageText;
21648
21701
  }
21649
- if (typeof t2 === "string") {
21650
- t2 = { messageText: t2 };
21702
+ const chain1 = typeof d1.messageText !== "string" ? d1.messageText.next : void 0;
21703
+ const chain2 = typeof d2.messageText !== "string" ? d2.messageText.next : void 0;
21704
+ let res = compareStringsCaseSensitive(headMsg1, headMsg2);
21705
+ if (res) {
21706
+ return res;
21651
21707
  }
21652
- const res = compareStringsCaseSensitive(t1.messageText, t2.messageText);
21708
+ res = compareMessageChain(chain1, chain2);
21653
21709
  if (res) {
21654
21710
  return res;
21655
21711
  }
21656
- return compareMessageChain(t1.next, t2.next);
21712
+ if (d1.canonicalHead && !d2.canonicalHead) {
21713
+ return -1 /* LessThan */;
21714
+ }
21715
+ if (d2.canonicalHead && !d1.canonicalHead) {
21716
+ return 1 /* GreaterThan */;
21717
+ }
21718
+ return 0 /* EqualTo */;
21657
21719
  }
21658
21720
  function compareMessageChain(c1, c2) {
21659
21721
  if (c1 === void 0 && c2 === void 0) {
@@ -21707,7 +21769,19 @@ function compareMessageChainContent(c1, c2) {
21707
21769
  return 0 /* EqualTo */;
21708
21770
  }
21709
21771
  function diagnosticsEqualityComparer(d1, d2) {
21710
- 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);
21772
+ const code1 = getDiagnosticCode(d1);
21773
+ const code2 = getDiagnosticCode(d2);
21774
+ const msg1 = getDiagnosticMessage(d1);
21775
+ const msg2 = getDiagnosticMessage(d2);
21776
+ 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);
21777
+ }
21778
+ function getDiagnosticCode(d) {
21779
+ var _a;
21780
+ return ((_a = d.canonicalHead) == null ? void 0 : _a.code) || d.code;
21781
+ }
21782
+ function getDiagnosticMessage(d) {
21783
+ var _a;
21784
+ return ((_a = d.canonicalHead) == null ? void 0 : _a.messageText) || d.messageText;
21711
21785
  }
21712
21786
  function messageTextEqualityComparer(m1, m2) {
21713
21787
  const t1 = typeof m1 === "string" ? m1 : m1.messageText;
@@ -50179,7 +50253,7 @@ function createTypeChecker(host) {
50179
50253
  var externalHelpersModule;
50180
50254
  var scanner2;
50181
50255
  var Symbol47 = objectAllocator.getSymbolConstructor();
50182
- var Type28 = objectAllocator.getTypeConstructor();
50256
+ var Type29 = objectAllocator.getTypeConstructor();
50183
50257
  var Signature14 = objectAllocator.getSignatureConstructor();
50184
50258
  var typeCount = 0;
50185
50259
  var symbolCount = 0;
@@ -50321,6 +50395,7 @@ function createTypeChecker(host) {
50321
50395
  getBaseTypes,
50322
50396
  getBaseTypeOfLiteralType,
50323
50397
  getWidenedType,
50398
+ getWidenedLiteralType,
50324
50399
  getTypeFromTypeNode: (nodeIn) => {
50325
50400
  const node = getParseTreeNode(nodeIn, isTypeNode);
50326
50401
  return node ? getTypeFromTypeNode(node) : errorType;
@@ -51826,6 +51901,7 @@ function createTypeChecker(host) {
51826
51901
  );
51827
51902
  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;
51828
51903
  const diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
51904
+ diagnostic.canonicalHead = getCanonicalDiagnostic(nameNotFoundMessage, diagnosticName(nameArg));
51829
51905
  addErrorOrSuggestion(!isUncheckedJS, diagnostic);
51830
51906
  if (suggestion.valueDeclaration) {
51831
51907
  addRelatedInfo(
@@ -52897,12 +52973,6 @@ function createTypeChecker(host) {
52897
52973
  }
52898
52974
  }
52899
52975
  }
52900
- function markConstEnumAliasAsReferenced(symbol) {
52901
- const links = getSymbolLinks(symbol);
52902
- if (!links.constEnumReferenced) {
52903
- links.constEnumReferenced = true;
52904
- }
52905
- }
52906
52976
  function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
52907
52977
  if (entityName.kind === 80 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
52908
52978
  entityName = entityName.parent;
@@ -53777,7 +53847,7 @@ function createTypeChecker(host) {
53777
53847
  }
53778
53848
  function createType(flags) {
53779
53849
  var _a;
53780
- const result = new Type28(checker, flags);
53850
+ const result = new Type29(checker, flags);
53781
53851
  typeCount++;
53782
53852
  result.id = typeCount;
53783
53853
  (_a = tracing) == null ? void 0 : _a.recordType(result);
@@ -53789,7 +53859,7 @@ function createTypeChecker(host) {
53789
53859
  return result;
53790
53860
  }
53791
53861
  function createOriginType(flags) {
53792
- return new Type28(checker, flags);
53862
+ return new Type29(checker, flags);
53793
53863
  }
53794
53864
  function createIntrinsicType(kind, intrinsicName, objectFlags = 0 /* None */, debugIntrinsicName) {
53795
53865
  checkIntrinsicName(intrinsicName, debugIntrinsicName);
@@ -54387,31 +54457,31 @@ function createTypeChecker(host) {
54387
54457
  }
54388
54458
  function createNodeBuilder() {
54389
54459
  return {
54390
- typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
54391
- typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
54392
- expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
54393
- serializeTypeForDeclaration: (declaration, type, symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, declaration, type, symbol)),
54394
- serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
54395
- indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
54460
+ typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
54461
+ typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
54462
+ expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
54463
+ serializeTypeForDeclaration: (declaration, type, symbol, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, declaration, type, symbol)),
54464
+ serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
54465
+ indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
54396
54466
  indexInfo,
54397
54467
  context,
54398
54468
  /*typeNode*/
54399
54469
  void 0
54400
54470
  )),
54401
- signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
54402
- symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToName(
54471
+ signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
54472
+ symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToName(
54403
54473
  symbol,
54404
54474
  context,
54405
54475
  meaning,
54406
54476
  /*expectsIdentifier*/
54407
54477
  false
54408
54478
  )),
54409
- symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
54410
- symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
54411
- symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
54412
- typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
54413
- symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
54414
- symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
54479
+ symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
54480
+ symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
54481
+ symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
54482
+ typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
54483
+ symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
54484
+ symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
54415
54485
  };
54416
54486
  function setTextRange2(context, range, location) {
54417
54487
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
@@ -54494,7 +54564,7 @@ function createTypeChecker(host) {
54494
54564
  }
54495
54565
  return symbolToExpression(symbol, context, meaning);
54496
54566
  }
54497
- function withContext(enclosingDeclaration, flags, tracker, cb) {
54567
+ function withContext2(enclosingDeclaration, flags, tracker, cb) {
54498
54568
  Debug.assert(enclosingDeclaration === void 0 || (enclosingDeclaration.flags & 16 /* Synthesized */) === 0);
54499
54569
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : flags & 134217728 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
54500
54570
  const context = {
@@ -59604,7 +59674,7 @@ function createTypeChecker(host) {
59604
59674
  }
59605
59675
  type = anyType;
59606
59676
  }
59607
- links.type = type;
59677
+ links.type ?? (links.type = type);
59608
59678
  }
59609
59679
  return links.type;
59610
59680
  }
@@ -59622,7 +59692,7 @@ function createTypeChecker(host) {
59622
59692
  }
59623
59693
  writeType = anyType;
59624
59694
  }
59625
- links.writeType = writeType || getTypeOfAccessors(symbol);
59695
+ links.writeType ?? (links.writeType = writeType || getTypeOfAccessors(symbol));
59626
59696
  }
59627
59697
  return links.writeType;
59628
59698
  }
@@ -59699,10 +59769,10 @@ function createTypeChecker(host) {
59699
59769
  true
59700
59770
  );
59701
59771
  const declaredType = firstDefined(exportSymbol == null ? void 0 : exportSymbol.declarations, (d) => isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : void 0);
59702
- 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;
59772
+ 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);
59703
59773
  if (!popTypeResolution()) {
59704
59774
  reportCircularityError(exportSymbol ?? symbol);
59705
- return links.type = errorType;
59775
+ return links.type ?? (links.type = errorType);
59706
59776
  }
59707
59777
  }
59708
59778
  return links.type;
@@ -59968,7 +60038,7 @@ function createTypeChecker(host) {
59968
60038
  }
59969
60039
  if (!popTypeResolution()) {
59970
60040
  error2(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
59971
- return type.resolvedBaseConstructorType = errorType;
60041
+ return type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = errorType);
59972
60042
  }
59973
60043
  if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
59974
60044
  const err = error2(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
@@ -59985,9 +60055,9 @@ function createTypeChecker(host) {
59985
60055
  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)));
59986
60056
  }
59987
60057
  }
59988
- return type.resolvedBaseConstructorType = errorType;
60058
+ return type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = errorType);
59989
60059
  }
59990
- type.resolvedBaseConstructorType = baseConstructorType;
60060
+ type.resolvedBaseConstructorType ?? (type.resolvedBaseConstructorType = baseConstructorType);
59991
60061
  }
59992
60062
  return type.resolvedBaseConstructorType;
59993
60063
  }
@@ -60228,7 +60298,7 @@ function createTypeChecker(host) {
60228
60298
  error2(isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
60229
60299
  }
60230
60300
  }
60231
- links.declaredType = type;
60301
+ links.declaredType ?? (links.declaredType = type);
60232
60302
  }
60233
60303
  return links.declaredType;
60234
60304
  }
@@ -61346,6 +61416,7 @@ function createTypeChecker(host) {
61346
61416
  }
61347
61417
  }
61348
61418
  function getTypeOfMappedSymbol(symbol) {
61419
+ var _a;
61349
61420
  if (!symbol.links.type) {
61350
61421
  const mappedType = symbol.links.mappedType;
61351
61422
  if (!pushTypeResolution(symbol, 0 /* Type */)) {
@@ -61364,7 +61435,7 @@ function createTypeChecker(host) {
61364
61435
  error2(currentNode, Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
61365
61436
  type = errorType;
61366
61437
  }
61367
- symbol.links.type = type;
61438
+ (_a = symbol.links).type ?? (_a.type = type);
61368
61439
  }
61369
61440
  return symbol.links.type;
61370
61441
  }
@@ -61717,7 +61788,7 @@ function createTypeChecker(host) {
61717
61788
  }
61718
61789
  result = circularConstraintType;
61719
61790
  }
61720
- t.immediateBaseConstraint = result || noConstraintType;
61791
+ t.immediateBaseConstraint ?? (t.immediateBaseConstraint = result || noConstraintType);
61721
61792
  }
61722
61793
  return t.immediateBaseConstraint;
61723
61794
  }
@@ -62591,7 +62662,7 @@ function createTypeChecker(host) {
62591
62662
  }
62592
62663
  type = anyType;
62593
62664
  }
62594
- signature.resolvedReturnType = type;
62665
+ signature.resolvedReturnType ?? (signature.resolvedReturnType = type);
62595
62666
  }
62596
62667
  return signature.resolvedReturnType;
62597
62668
  }
@@ -62937,9 +63008,9 @@ function createTypeChecker(host) {
62937
63008
  const node = type.node;
62938
63009
  const typeArguments = !node ? emptyArray : node.kind === 183 /* TypeReference */ ? concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments2(node, type.target.localTypeParameters)) : node.kind === 188 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : map(node.elements, getTypeFromTypeNode);
62939
63010
  if (popTypeResolution()) {
62940
- type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
63011
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments);
62941
63012
  } else {
62942
- type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray;
63013
+ type.resolvedTypeArguments ?? (type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray);
62943
63014
  error2(
62944
63015
  type.node || currentNode,
62945
63016
  type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
@@ -67998,6 +68069,16 @@ function createTypeChecker(host) {
67998
68069
  errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
67999
68070
  }
68000
68071
  if (!headMessage2 && maybeSuppress) {
68072
+ const savedErrorState = captureErrorCalculationState();
68073
+ reportRelationError(headMessage2, source2, target2);
68074
+ let canonical;
68075
+ if (errorInfo && errorInfo !== savedErrorState.errorInfo) {
68076
+ canonical = { code: errorInfo.code, messageText: errorInfo.messageText };
68077
+ }
68078
+ resetErrorInfo(savedErrorState);
68079
+ if (canonical && errorInfo) {
68080
+ errorInfo.canonicalHead = canonical;
68081
+ }
68001
68082
  lastSkippedInfo = [source2, target2];
68002
68083
  return;
68003
68084
  }
@@ -69986,6 +70067,7 @@ function createTypeChecker(host) {
69986
70067
  if (!links.variances) {
69987
70068
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
69988
70069
  const oldVarianceComputation = inVarianceComputation;
70070
+ const saveResolutionStart = resolutionStart;
69989
70071
  if (!inVarianceComputation) {
69990
70072
  inVarianceComputation = true;
69991
70073
  resolutionStart = resolutionTargets.length;
@@ -70020,7 +70102,7 @@ function createTypeChecker(host) {
70020
70102
  }
70021
70103
  if (!oldVarianceComputation) {
70022
70104
  inVarianceComputation = false;
70023
- resolutionStart = 0;
70105
+ resolutionStart = saveResolutionStart;
70024
70106
  }
70025
70107
  links.variances = variances;
70026
70108
  (_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
@@ -74213,7 +74295,7 @@ function createTypeChecker(host) {
74213
74295
  reportCircularityError(declaration.symbol);
74214
74296
  return true;
74215
74297
  }
74216
- links.parameterInitializerContainsUndefined = containsUndefined;
74298
+ links.parameterInitializerContainsUndefined ?? (links.parameterInitializerContainsUndefined = containsUndefined);
74217
74299
  }
74218
74300
  return links.parameterInitializerContainsUndefined;
74219
74301
  }
@@ -74275,8 +74357,6 @@ function createTypeChecker(host) {
74275
74357
  ) & (111551 /* Value */ | 1048576 /* ExportValue */)) {
74276
74358
  if (getIsolatedModules(compilerOptions) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
74277
74359
  markAliasSymbolAsReferenced(symbol);
74278
- } else {
74279
- markConstEnumAliasAsReferenced(symbol);
74280
74360
  }
74281
74361
  }
74282
74362
  }
@@ -75533,60 +75613,71 @@ function createTypeChecker(host) {
75533
75613
  return false;
75534
75614
  }
75535
75615
  function discriminateContextualTypeByObjectMembers(node, contextualType) {
75536
- return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(
75537
- contextualType,
75538
- concatenate(
75539
- map(
75540
- filter(node.properties, (p) => {
75541
- if (!p.symbol) {
75616
+ const key = `D${getNodeId(node)},${getTypeId(contextualType)}`;
75617
+ return getCachedType(key) ?? setCachedType(
75618
+ key,
75619
+ getMatchingUnionConstituentForObjectLiteral(contextualType, node) ?? discriminateTypeByDiscriminableItems(
75620
+ contextualType,
75621
+ concatenate(
75622
+ map(
75623
+ filter(node.properties, (p) => {
75624
+ if (!p.symbol) {
75625
+ return false;
75626
+ }
75627
+ if (p.kind === 303 /* PropertyAssignment */) {
75628
+ return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
75629
+ }
75630
+ if (p.kind === 304 /* ShorthandPropertyAssignment */) {
75631
+ return isDiscriminantProperty(contextualType, p.symbol.escapedName);
75632
+ }
75542
75633
  return false;
75543
- }
75544
- if (p.kind === 303 /* PropertyAssignment */) {
75545
- return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
75546
- }
75547
- if (p.kind === 304 /* ShorthandPropertyAssignment */) {
75548
- return isDiscriminantProperty(contextualType, p.symbol.escapedName);
75549
- }
75550
- return false;
75551
- }),
75552
- (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
75634
+ }),
75635
+ (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
75636
+ ),
75637
+ map(
75638
+ filter(getPropertiesOfType(contextualType), (s) => {
75639
+ var _a;
75640
+ return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75641
+ }),
75642
+ (s) => [() => undefinedType, s.escapedName]
75643
+ )
75553
75644
  ),
75554
- map(
75555
- filter(getPropertiesOfType(contextualType), (s) => {
75556
- var _a;
75557
- return !!(s.flags & 16777216 /* Optional */) && !!((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75558
- }),
75559
- (s) => [() => undefinedType, s.escapedName]
75560
- )
75561
- ),
75562
- isTypeAssignableTo
75645
+ isTypeAssignableTo
75646
+ )
75563
75647
  );
75564
75648
  }
75565
75649
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
75650
+ const key = `D${getNodeId(node)},${getTypeId(contextualType)}`;
75651
+ const cached = getCachedType(key);
75652
+ if (cached)
75653
+ return cached;
75566
75654
  const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
75567
- return discriminateTypeByDiscriminableItems(
75568
- contextualType,
75569
- concatenate(
75570
- map(
75571
- filter(node.properties, (p) => !!p.symbol && p.kind === 291 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer))),
75572
- (prop) => [!prop.initializer ? () => trueType : () => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
75655
+ return setCachedType(
75656
+ key,
75657
+ discriminateTypeByDiscriminableItems(
75658
+ contextualType,
75659
+ concatenate(
75660
+ map(
75661
+ filter(node.properties, (p) => !!p.symbol && p.kind === 291 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer))),
75662
+ (prop) => [!prop.initializer ? () => trueType : () => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
75663
+ ),
75664
+ map(
75665
+ filter(getPropertiesOfType(contextualType), (s) => {
75666
+ var _a;
75667
+ if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
75668
+ return false;
75669
+ }
75670
+ const element = node.parent.parent;
75671
+ if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
75672
+ return false;
75673
+ }
75674
+ return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75675
+ }),
75676
+ (s) => [() => undefinedType, s.escapedName]
75677
+ )
75573
75678
  ),
75574
- map(
75575
- filter(getPropertiesOfType(contextualType), (s) => {
75576
- var _a;
75577
- if (!(s.flags & 16777216 /* Optional */) || !((_a = node == null ? void 0 : node.symbol) == null ? void 0 : _a.members)) {
75578
- return false;
75579
- }
75580
- const element = node.parent.parent;
75581
- if (s.escapedName === jsxChildrenPropertyName && isJsxElement(element) && getSemanticJsxChildren(element.children).length) {
75582
- return false;
75583
- }
75584
- return !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName);
75585
- }),
75586
- (s) => [() => undefinedType, s.escapedName]
75587
- )
75588
- ),
75589
- isTypeAssignableTo
75679
+ isTypeAssignableTo
75680
+ )
75590
75681
  );
75591
75682
  }
75592
75683
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -76020,7 +76111,7 @@ function createTypeChecker(host) {
76020
76111
  }
76021
76112
  function checkGrammarRegularExpressionLiteral(node) {
76022
76113
  const sourceFile = getSourceFileOfNode(node);
76023
- if (!hasParseDiagnostics(sourceFile)) {
76114
+ if (!hasParseDiagnostics(sourceFile) && !node.isUnterminated) {
76024
76115
  let lastError;
76025
76116
  scanner2 ?? (scanner2 = createScanner(
76026
76117
  99 /* ESNext */,
@@ -79622,8 +79713,13 @@ function createTypeChecker(host) {
79622
79713
  if (cached && cached !== resolvingSignature && !candidatesOutArray) {
79623
79714
  return cached;
79624
79715
  }
79716
+ const saveResolutionStart = resolutionStart;
79717
+ if (!cached) {
79718
+ resolutionStart = resolutionTargets.length;
79719
+ }
79625
79720
  links.resolvedSignature = resolvingSignature;
79626
79721
  let result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
79722
+ resolutionStart = saveResolutionStart;
79627
79723
  if (result !== resolvingSignature) {
79628
79724
  if (links.resolvedSignature !== resolvingSignature) {
79629
79725
  result = links.resolvedSignature;
@@ -142796,6 +142892,7 @@ __export(ts_refactor_exports, {
142796
142892
  generateGetAccessorAndSetAccessor: () => ts_refactor_generateGetAccessorAndSetAccessor_exports,
142797
142893
  getApplicableRefactors: () => getApplicableRefactors,
142798
142894
  getEditsForRefactor: () => getEditsForRefactor,
142895
+ getIdentifierForNode: () => getIdentifierForNode,
142799
142896
  getNewStatementsAndRemoveFromOldFile: () => getNewStatementsAndRemoveFromOldFile,
142800
142897
  getStatementsToMove: () => getStatementsToMove,
142801
142898
  getTopLevelDeclarationStatement: () => getTopLevelDeclarationStatement,
@@ -144524,6 +144621,15 @@ function refactorKindBeginsWith(known, requested) {
144524
144621
  return true;
144525
144622
  return known.substr(0, requested.length) === requested;
144526
144623
  }
144624
+ function getIdentifierForNode(node, scope, checker, file) {
144625
+ return isPropertyAccessExpression(node) && !isClassLike(scope) && !checker.resolveName(
144626
+ node.name.text,
144627
+ node,
144628
+ 111551 /* Value */,
144629
+ /*excludeGlobals*/
144630
+ false
144631
+ ) && !isPrivateIdentifier(node.name) && !identifierToKeywordKind(node.name) ? node.name.text : getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file);
144632
+ }
144527
144633
  function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFile, checker, program, importAdder) {
144528
144634
  importsToCopy.forEach(([isValidTypeOnlyUseSite, declaration], symbol) => {
144529
144635
  var _a;
@@ -147207,13 +147313,7 @@ function extractFunctionInScope(node, scope, { usages: usagesInScope, typeParame
147207
147313
  function extractConstantInScope(node, scope, { substitutions }, rangeFacts, context) {
147208
147314
  const checker = context.program.getTypeChecker();
147209
147315
  const file = scope.getSourceFile();
147210
- const localNameText = isPropertyAccessExpression(node) && !isClassLike(scope) && !checker.resolveName(
147211
- node.name.text,
147212
- node,
147213
- 111551 /* Value */,
147214
- /*excludeGlobals*/
147215
- false
147216
- ) && !isPrivateIdentifier(node.name) && !identifierToKeywordKind(node.name) ? node.name.text : getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file);
147316
+ const localNameText = getIdentifierForNode(node, scope, checker, file);
147217
147317
  const isJS = isInJSFile(scope);
147218
147318
  let variableType = isJS || !checker.isContextSensitive(node) ? void 0 : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */);
147219
147319
  let initializer = transformConstantInitializer(skipParentheses(node), substitutions);
@@ -149781,22 +149881,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
149781
149881
  }
149782
149882
  return [];
149783
149883
  }
149784
- function getCodeFixesAtPosition(fileName, start, end, errorCodes66, formatOptions, preferences = emptyOptions) {
149884
+ function getCodeFixesAtPosition(fileName, start, end, errorCodes67, formatOptions, preferences = emptyOptions) {
149785
149885
  synchronizeHostData();
149786
149886
  const sourceFile = getValidSourceFile(fileName);
149787
149887
  const span = createTextSpanFromBounds(start, end);
149788
149888
  const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
149789
- return flatMap(deduplicate(errorCodes66, equateValues, compareValues), (errorCode) => {
149889
+ return flatMap(deduplicate(errorCodes67, equateValues, compareValues), (errorCode) => {
149790
149890
  cancellationToken.throwIfCancellationRequested();
149791
149891
  return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
149792
149892
  });
149793
149893
  }
149794
- function getCombinedCodeFix(scope, fixId53, formatOptions, preferences = emptyOptions) {
149894
+ function getCombinedCodeFix(scope, fixId54, formatOptions, preferences = emptyOptions) {
149795
149895
  synchronizeHostData();
149796
149896
  Debug.assert(scope.type === "file");
149797
149897
  const sourceFile = getValidSourceFile(scope.fileName);
149798
149898
  const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
149799
- return ts_codefix_exports.getAllFixes({ fixId: fixId53, sourceFile, program, host, cancellationToken, formatContext, preferences });
149899
+ return ts_codefix_exports.getAllFixes({ fixId: fixId54, sourceFile, program, host, cancellationToken, formatContext, preferences });
149800
149900
  }
149801
149901
  function organizeImports2(args, formatOptions, preferences = emptyOptions) {
149802
149902
  synchronizeHostData();
@@ -151475,14 +151575,14 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description3) {
151475
151575
  void 0
151476
151576
  );
151477
151577
  }
151478
- function createCodeFixAction(fixName8, changes, description3, fixId53, fixAllDescription, command) {
151479
- return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, diagnosticToString(fixAllDescription), command);
151578
+ function createCodeFixAction(fixName8, changes, description3, fixId54, fixAllDescription, command) {
151579
+ return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId54, diagnosticToString(fixAllDescription), command);
151480
151580
  }
151481
- function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId53, fixAllDescription, command) {
151482
- return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, fixAllDescription && diagnosticToString(fixAllDescription), command);
151581
+ function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId54, fixAllDescription, command) {
151582
+ return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId54, fixAllDescription && diagnosticToString(fixAllDescription), command);
151483
151583
  }
151484
- function createCodeFixActionWorker(fixName8, description3, changes, fixId53, fixAllDescription, command) {
151485
- return { fixName: fixName8, description: description3, changes, fixId: fixId53, fixAllDescription, commands: command ? [command] : void 0 };
151584
+ function createCodeFixActionWorker(fixName8, description3, changes, fixId54, fixAllDescription, command) {
151585
+ return { fixName: fixName8, description: description3, changes, fixId: fixId54, fixAllDescription, commands: command ? [command] : void 0 };
151486
151586
  }
151487
151587
  function registerCodeFix(reg) {
151488
151588
  for (const error2 of reg.errorCodes) {
@@ -151490,9 +151590,9 @@ function registerCodeFix(reg) {
151490
151590
  errorCodeToFixes.add(String(error2), reg);
151491
151591
  }
151492
151592
  if (reg.fixIds) {
151493
- for (const fixId53 of reg.fixIds) {
151494
- Debug.assert(!fixIdToRegistration.has(fixId53));
151495
- fixIdToRegistration.set(fixId53, reg);
151593
+ for (const fixId54 of reg.fixIds) {
151594
+ Debug.assert(!fixIdToRegistration.has(fixId54));
151595
+ fixIdToRegistration.set(fixId54, reg);
151496
151596
  }
151497
151597
  }
151498
151598
  }
@@ -151501,17 +151601,17 @@ function getSupportedErrorCodes() {
151501
151601
  return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
151502
151602
  }
151503
151603
  function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
151504
- const { errorCodes: errorCodes66 } = registration;
151604
+ const { errorCodes: errorCodes67 } = registration;
151505
151605
  let maybeFixableDiagnostics = 0;
151506
151606
  for (const diag2 of diagnostics) {
151507
- if (contains(errorCodes66, diag2.code))
151607
+ if (contains(errorCodes67, diag2.code))
151508
151608
  maybeFixableDiagnostics++;
151509
151609
  if (maybeFixableDiagnostics > 1)
151510
151610
  break;
151511
151611
  }
151512
151612
  const fixAllUnavailable = maybeFixableDiagnostics < 2;
151513
- return ({ fixId: fixId53, fixAllDescription, ...action }) => {
151514
- return fixAllUnavailable ? action : { ...action, fixId: fixId53, fixAllDescription };
151613
+ return ({ fixId: fixId54, fixAllDescription, ...action }) => {
151614
+ return fixAllUnavailable ? action : { ...action, fixId: fixId54, fixAllDescription };
151515
151615
  };
151516
151616
  }
151517
151617
  function getFixes(context) {
@@ -151528,24 +151628,30 @@ function createCombinedCodeActions(changes, commands) {
151528
151628
  function createFileTextChanges(fileName, textChanges2) {
151529
151629
  return { fileName, textChanges: textChanges2 };
151530
151630
  }
151531
- function codeFixAll(context, errorCodes66, use) {
151631
+ function codeFixAll(context, errorCodes67, use) {
151532
151632
  const commands = [];
151533
- const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes66, (diag2) => use(t, diag2, commands)));
151633
+ const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes67, (diag2) => use(t, diag2, commands)));
151534
151634
  return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
151535
151635
  }
151536
- function eachDiagnostic(context, errorCodes66, cb) {
151636
+ function eachDiagnostic(context, errorCodes67, cb) {
151537
151637
  for (const diag2 of getDiagnostics(context)) {
151538
- if (contains(errorCodes66, diag2.code)) {
151638
+ if (contains(errorCodes67, diag2.code)) {
151539
151639
  cb(diag2);
151540
151640
  }
151541
151641
  }
151542
151642
  }
151543
151643
  function getDiagnostics({ program, sourceFile, cancellationToken }) {
151544
- return [
151644
+ const diagnostics = [
151545
151645
  ...program.getSemanticDiagnostics(sourceFile, cancellationToken),
151546
151646
  ...program.getSyntacticDiagnostics(sourceFile, cancellationToken),
151547
151647
  ...computeSuggestionDiagnostics(sourceFile, program, cancellationToken)
151548
151648
  ];
151649
+ if (getEmitDeclarations(program.getCompilerOptions())) {
151650
+ diagnostics.push(
151651
+ ...program.getDeclarationDiagnostics(sourceFile, cancellationToken)
151652
+ );
151653
+ }
151654
+ return diagnostics;
151549
151655
  }
151550
151656
 
151551
151657
  // src/services/codefixes/addConvertToUnknownForNonOverlappingTypes.ts
@@ -156233,10 +156339,10 @@ registerCodeFix({
156233
156339
  const info = errorCodeFixIdMap[errorCode];
156234
156340
  if (!info)
156235
156341
  return emptyArray;
156236
- const { descriptions, fixId: fixId53, fixAllDescriptions } = info;
156342
+ const { descriptions, fixId: fixId54, fixAllDescriptions } = info;
156237
156343
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
156238
156344
  return [
156239
- createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId53, fixAllDescriptions)
156345
+ createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId54, fixAllDescriptions)
156240
156346
  ];
156241
156347
  },
156242
156348
  fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
@@ -157041,7 +157147,7 @@ registerCodeFix({
157041
157147
  },
157042
157148
  fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
157043
157149
  getAllCodeActions: (context) => {
157044
- const { program, fixId: fixId53 } = context;
157150
+ const { program, fixId: fixId54 } = context;
157045
157151
  const checker = program.getTypeChecker();
157046
157152
  const seen = /* @__PURE__ */ new Map();
157047
157153
  const typeDeclToMembers = /* @__PURE__ */ new Map();
@@ -157051,11 +157157,11 @@ registerCodeFix({
157051
157157
  if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
157052
157158
  return;
157053
157159
  }
157054
- if (fixId53 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
157160
+ if (fixId54 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
157055
157161
  addFunctionDeclaration(changes, context, info);
157056
- } else if (fixId53 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157162
+ } else if (fixId54 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
157057
157163
  addObjectLiteralProperties(changes, context, info);
157058
- } else if (fixId53 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157164
+ } else if (fixId54 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
157059
157165
  addJsxAttributes(changes, context, info);
157060
157166
  } else {
157061
157167
  if (info.kind === 1 /* Enum */) {
@@ -157690,7 +157796,7 @@ registerCodeFix({
157690
157796
  actions2,
157691
157797
  createCodeFixAction(
157692
157798
  addMissingParamFixId,
157693
- ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, declarations, newParameters)),
157799
+ ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.program, context.preferences, context.host, declarations, newParameters)),
157694
157800
  [length(newParameters) > 1 ? Diagnostics.Add_missing_parameters_to_0 : Diagnostics.Add_missing_parameter_to_0, name],
157695
157801
  addMissingParamFixId,
157696
157802
  Diagnostics.Add_all_missing_parameters
@@ -157702,7 +157808,7 @@ registerCodeFix({
157702
157808
  actions2,
157703
157809
  createCodeFixAction(
157704
157810
  addOptionalParamFixId,
157705
- ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, declarations, newOptionalParameters)),
157811
+ ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.program, context.preferences, context.host, declarations, newOptionalParameters)),
157706
157812
  [length(newOptionalParameters) > 1 ? Diagnostics.Add_optional_parameters_to_0 : Diagnostics.Add_optional_parameter_to_0, name],
157707
157813
  addOptionalParamFixId,
157708
157814
  Diagnostics.Add_all_optional_parameters
@@ -157716,10 +157822,10 @@ registerCodeFix({
157716
157822
  if (info) {
157717
157823
  const { declarations, newParameters, newOptionalParameters } = info;
157718
157824
  if (context.fixId === addMissingParamFixId) {
157719
- doChange19(changes, context.sourceFile, declarations, newParameters);
157825
+ doChange19(changes, context.program, context.preferences, context.host, declarations, newParameters);
157720
157826
  }
157721
157827
  if (context.fixId === addOptionalParamFixId) {
157722
- doChange19(changes, context.sourceFile, declarations, newOptionalParameters);
157828
+ doChange19(changes, context.program, context.preferences, context.host, declarations, newOptionalParameters);
157723
157829
  }
157724
157830
  }
157725
157831
  })
@@ -157799,14 +157905,17 @@ function tryGetName2(node) {
157799
157905
  function typeToTypeNode(checker, type, enclosingDeclaration) {
157800
157906
  return checker.typeToTypeNode(checker.getWidenedType(type), enclosingDeclaration, 1 /* NoTruncation */) ?? factory.createKeywordTypeNode(159 /* UnknownKeyword */);
157801
157907
  }
157802
- function doChange19(changes, sourceFile, declarations, newParameters) {
157908
+ function doChange19(changes, program, preferences, host, declarations, newParameters) {
157909
+ const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
157803
157910
  forEach(declarations, (declaration) => {
157911
+ const sourceFile = getSourceFileOfNode(declaration);
157912
+ const importAdder = createImportAdder(sourceFile, program, preferences, host);
157804
157913
  if (length(declaration.parameters)) {
157805
157914
  changes.replaceNodeRangeWithNodes(
157806
157915
  sourceFile,
157807
157916
  first(declaration.parameters),
157808
157917
  last(declaration.parameters),
157809
- updateParameters(declaration, newParameters),
157918
+ updateParameters(importAdder, scriptTarget, declaration, newParameters),
157810
157919
  {
157811
157920
  joiner: ", ",
157812
157921
  indentation: 0,
@@ -157815,7 +157924,7 @@ function doChange19(changes, sourceFile, declarations, newParameters) {
157815
157924
  }
157816
157925
  );
157817
157926
  } else {
157818
- forEach(updateParameters(declaration, newParameters), (parameter, index) => {
157927
+ forEach(updateParameters(importAdder, scriptTarget, declaration, newParameters), (parameter, index) => {
157819
157928
  if (length(declaration.parameters) === 0 && index === 0) {
157820
157929
  changes.insertNodeAt(sourceFile, declaration.parameters.end, parameter);
157821
157930
  } else {
@@ -157823,6 +157932,7 @@ function doChange19(changes, sourceFile, declarations, newParameters) {
157823
157932
  }
157824
157933
  });
157825
157934
  }
157935
+ importAdder.writeFixes(changes);
157826
157936
  });
157827
157937
  }
157828
157938
  function isConvertibleSignatureDeclaration(node) {
@@ -157836,7 +157946,7 @@ function isConvertibleSignatureDeclaration(node) {
157836
157946
  return false;
157837
157947
  }
157838
157948
  }
157839
- function updateParameters(node, newParameters) {
157949
+ function updateParameters(importAdder, scriptTarget, node, newParameters) {
157840
157950
  const parameters = map(node.parameters, (p) => factory.createParameterDeclaration(
157841
157951
  p.modifiers,
157842
157952
  p.dotDotDotToken,
@@ -157856,7 +157966,7 @@ function updateParameters(node, newParameters) {
157856
157966
  declaration.dotDotDotToken,
157857
157967
  declaration.name,
157858
157968
  prev && prev.questionToken ? factory.createToken(58 /* QuestionToken */) : declaration.questionToken,
157859
- declaration.type,
157969
+ getParameterType(importAdder, declaration.type, scriptTarget),
157860
157970
  declaration.initializer
157861
157971
  )
157862
157972
  );
@@ -157897,6 +158007,14 @@ function createParameter(name, type, questionToken) {
157897
158007
  function isOptionalPos(declarations, pos) {
157898
158008
  return length(declarations) && some(declarations, (d) => pos < length(d.parameters) && !!d.parameters[pos] && d.parameters[pos].questionToken === void 0);
157899
158009
  }
158010
+ function getParameterType(importAdder, typeNode, scriptTarget) {
158011
+ const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
158012
+ if (importableReference) {
158013
+ importSymbols(importAdder, importableReference.symbols);
158014
+ return importableReference.typeNode;
158015
+ }
158016
+ return typeNode;
158017
+ }
157900
158018
 
157901
158019
  // src/services/codefixes/fixCannotFindModule.ts
157902
158020
  var fixName2 = "fixCannotFindModule";
@@ -158965,21 +159083,21 @@ registerCodeFix({
158965
159083
  actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
158966
159084
  }
158967
159085
  return actions2;
158968
- function fix(type2, fixId53, fixAllDescription) {
159086
+ function fix(type2, fixId54, fixAllDescription) {
158969
159087
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
158970
- return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId53, fixAllDescription);
159088
+ return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId54, fixAllDescription);
158971
159089
  }
158972
159090
  },
158973
159091
  fixIds: [fixIdPlain, fixIdNullable],
158974
159092
  getAllCodeActions(context) {
158975
- const { fixId: fixId53, program, sourceFile } = context;
159093
+ const { fixId: fixId54, program, sourceFile } = context;
158976
159094
  const checker = program.getTypeChecker();
158977
159095
  return codeFixAll(context, errorCodes45, (changes, err) => {
158978
159096
  const info = getInfo15(err.file, err.start, checker);
158979
159097
  if (!info)
158980
159098
  return;
158981
159099
  const { typeNode, type } = info;
158982
- const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId53 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
159100
+ const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId54 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
158983
159101
  doChange29(changes, sourceFile, typeNode, fixedType, checker);
158984
159102
  });
158985
159103
  }
@@ -159074,28 +159192,909 @@ function getCallName(sourceFile, start) {
159074
159192
  return void 0;
159075
159193
  }
159076
159194
 
159077
- // src/services/codefixes/fixAwaitInSyncFunction.ts
159078
- var fixId36 = "fixAwaitInSyncFunction";
159195
+ // src/services/codefixes/fixMissingTypeAnnotationOnExports.ts
159196
+ var fixId36 = "fixMissingTypeAnnotationOnExports";
159197
+ var addAnnotationFix = "add-annotation";
159198
+ var addInlineTypeAssertion = "add-type-assertion";
159199
+ var extractExpression = "extract-expression";
159079
159200
  var errorCodes47 = [
159201
+ Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
159202
+ Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
159203
+ Diagnostics.At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
159204
+ Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
159205
+ Diagnostics.Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
159206
+ Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
159207
+ Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations.code,
159208
+ Diagnostics.Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations.code,
159209
+ Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations.code,
159210
+ Diagnostics.Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations.code,
159211
+ Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations.code,
159212
+ Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations.code,
159213
+ Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations.code,
159214
+ Diagnostics.Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations.code,
159215
+ Diagnostics.Default_exports_can_t_be_inferred_with_isolatedDeclarations.code,
159216
+ Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations.code,
159217
+ Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function.code,
159218
+ Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations.code,
159219
+ Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit.code
159220
+ ];
159221
+ var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
159222
+ 177 /* GetAccessor */,
159223
+ 174 /* MethodDeclaration */,
159224
+ 172 /* PropertyDeclaration */,
159225
+ 262 /* FunctionDeclaration */,
159226
+ 218 /* FunctionExpression */,
159227
+ 219 /* ArrowFunction */,
159228
+ 260 /* VariableDeclaration */,
159229
+ 169 /* Parameter */,
159230
+ 277 /* ExportAssignment */,
159231
+ 263 /* ClassDeclaration */,
159232
+ 206 /* ObjectBindingPattern */,
159233
+ 207 /* ArrayBindingPattern */
159234
+ ]);
159235
+ var declarationEmitNodeBuilderFlags2 = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */ | 1073741824 /* WriteComputedProps */;
159236
+ registerCodeFix({
159237
+ errorCodes: errorCodes47,
159238
+ fixIds: [fixId36],
159239
+ getCodeActions(context) {
159240
+ const fixes = [];
159241
+ addCodeAction(addAnnotationFix, fixes, context, 0 /* Full */, (f) => f.addTypeAnnotation(context.span));
159242
+ addCodeAction(addAnnotationFix, fixes, context, 1 /* Relative */, (f) => f.addTypeAnnotation(context.span));
159243
+ addCodeAction(addAnnotationFix, fixes, context, 2 /* Widened */, (f) => f.addTypeAnnotation(context.span));
159244
+ addCodeAction(addInlineTypeAssertion, fixes, context, 0 /* Full */, (f) => f.addInlineAssertion(context.span));
159245
+ addCodeAction(addInlineTypeAssertion, fixes, context, 1 /* Relative */, (f) => f.addInlineAssertion(context.span));
159246
+ addCodeAction(addAnnotationFix, fixes, context, 2 /* Widened */, (f) => f.addInlineAssertion(context.span));
159247
+ addCodeAction(extractExpression, fixes, context, 0 /* Full */, (f) => f.extractAsVariable(context.span));
159248
+ return fixes;
159249
+ },
159250
+ getAllCodeActions: (context) => {
159251
+ const changes = withContext(context, 0 /* Full */, (f) => {
159252
+ eachDiagnostic(context, errorCodes47, (diag2) => {
159253
+ f.addTypeAnnotation(diag2);
159254
+ });
159255
+ });
159256
+ return createCombinedCodeActions(changes.textChanges);
159257
+ }
159258
+ });
159259
+ function addCodeAction(fixName8, fixes, context, typePrintMode, cb) {
159260
+ const changes = withContext(context, typePrintMode, cb);
159261
+ if (changes.result && changes.textChanges.length) {
159262
+ fixes.push(createCodeFixAction(
159263
+ fixName8,
159264
+ changes.textChanges,
159265
+ changes.result,
159266
+ fixId36,
159267
+ Diagnostics.Add_all_missing_type_annotations
159268
+ ));
159269
+ }
159270
+ }
159271
+ function withContext(context, typePrintMode, cb) {
159272
+ const emptyInferenceResult = { typeNode: void 0, mutatedTarget: false };
159273
+ const changeTracker = ts_textChanges_exports.ChangeTracker.fromContext(context);
159274
+ const sourceFile = context.sourceFile;
159275
+ const program = context.program;
159276
+ const typeChecker = program.getTypeChecker();
159277
+ const emitResolver = typeChecker.getEmitResolver();
159278
+ const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
159279
+ const importAdder = createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
159280
+ const fixedNodes = /* @__PURE__ */ new Set();
159281
+ const expandoPropertiesAdded = /* @__PURE__ */ new Set();
159282
+ const typePrinter = createPrinter({
159283
+ preserveSourceNewlines: false
159284
+ });
159285
+ const result = cb({ addTypeAnnotation, addInlineAssertion, extractAsVariable });
159286
+ importAdder.writeFixes(changeTracker);
159287
+ return {
159288
+ result,
159289
+ textChanges: changeTracker.getChanges()
159290
+ };
159291
+ function addTypeAnnotation(span) {
159292
+ const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
159293
+ const expandoFunction = findExpandoFunction(nodeWithDiag);
159294
+ if (expandoFunction) {
159295
+ if (isFunctionDeclaration(expandoFunction)) {
159296
+ return createNamespaceForExpandoProperties(expandoFunction);
159297
+ }
159298
+ return fixIsolatedDeclarationError(expandoFunction);
159299
+ }
159300
+ const nodeMissingType = findAncestorWithMissingType(nodeWithDiag);
159301
+ if (nodeMissingType) {
159302
+ return fixIsolatedDeclarationError(nodeMissingType);
159303
+ }
159304
+ return void 0;
159305
+ }
159306
+ function createNamespaceForExpandoProperties(expandoFunc) {
159307
+ var _a;
159308
+ if (expandoPropertiesAdded == null ? void 0 : expandoPropertiesAdded.has(expandoFunc))
159309
+ return void 0;
159310
+ expandoPropertiesAdded == null ? void 0 : expandoPropertiesAdded.add(expandoFunc);
159311
+ const type = typeChecker.getTypeAtLocation(expandoFunc);
159312
+ const elements = typeChecker.getPropertiesOfType(type);
159313
+ if (!expandoFunc.name || elements.length === 0)
159314
+ return void 0;
159315
+ const newProperties = [];
159316
+ for (const symbol of elements) {
159317
+ if (!isIdentifierText(symbol.name, getEmitScriptTarget(program.getCompilerOptions())))
159318
+ continue;
159319
+ if (symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration))
159320
+ continue;
159321
+ newProperties.push(factory.createVariableStatement(
159322
+ [factory.createModifier(95 /* ExportKeyword */)],
159323
+ factory.createVariableDeclarationList(
159324
+ [factory.createVariableDeclaration(
159325
+ symbol.name,
159326
+ /*exclamationToken*/
159327
+ void 0,
159328
+ typeToTypeNode2(typeChecker.getTypeOfSymbol(symbol), expandoFunc),
159329
+ /*initializer*/
159330
+ void 0
159331
+ )]
159332
+ )
159333
+ ));
159334
+ }
159335
+ if (newProperties.length === 0)
159336
+ return void 0;
159337
+ const modifiers = [];
159338
+ if ((_a = expandoFunc.modifiers) == null ? void 0 : _a.some((modifier) => modifier.kind === 95 /* ExportKeyword */)) {
159339
+ modifiers.push(factory.createModifier(95 /* ExportKeyword */));
159340
+ }
159341
+ modifiers.push(factory.createModifier(138 /* DeclareKeyword */));
159342
+ const namespace = factory.createModuleDeclaration(
159343
+ modifiers,
159344
+ expandoFunc.name,
159345
+ factory.createModuleBlock(newProperties),
159346
+ /*flags*/
159347
+ 32 /* Namespace */ | 128 /* ExportContext */ | 33554432 /* Ambient */ | 101441536 /* ContextFlags */
159348
+ );
159349
+ changeTracker.insertNodeAfter(sourceFile, expandoFunc, namespace);
159350
+ return [Diagnostics.Annotate_types_of_properties_expando_function_in_a_namespace];
159351
+ }
159352
+ function needsParenthesizedExpressionForAssertion(node) {
159353
+ return !isEntityNameExpression(node) && !isCallExpression(node) && !isObjectLiteralExpression(node) && !isArrayLiteralExpression(node);
159354
+ }
159355
+ function createAsExpression(node, type) {
159356
+ if (needsParenthesizedExpressionForAssertion(node)) {
159357
+ node = factory.createParenthesizedExpression(node);
159358
+ }
159359
+ return factory.createAsExpression(node, type);
159360
+ }
159361
+ function createSatisfiesAsExpression(node, type) {
159362
+ if (needsParenthesizedExpressionForAssertion(node)) {
159363
+ node = factory.createParenthesizedExpression(node);
159364
+ }
159365
+ return factory.createAsExpression(factory.createSatisfiesExpression(node, getSynthesizedDeepClone(type)), type);
159366
+ }
159367
+ function addInlineAssertion(span) {
159368
+ const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
159369
+ const expandoFunction = findExpandoFunction(nodeWithDiag);
159370
+ if (expandoFunction)
159371
+ return;
159372
+ const targetNode = findBestFittingNode(nodeWithDiag, span);
159373
+ if (!targetNode || isValueSignatureDeclaration(targetNode) || isValueSignatureDeclaration(targetNode.parent))
159374
+ return;
159375
+ const isExpressionTarget = isExpression(targetNode);
159376
+ const isShorthandPropertyAssignmentTarget = isShorthandPropertyAssignment(targetNode);
159377
+ if (!isShorthandPropertyAssignmentTarget && isDeclaration(targetNode)) {
159378
+ return void 0;
159379
+ }
159380
+ if (findAncestor(targetNode, isBindingPattern)) {
159381
+ return void 0;
159382
+ }
159383
+ if (findAncestor(targetNode, isEnumMember)) {
159384
+ return void 0;
159385
+ }
159386
+ if (isExpressionTarget && findAncestor(targetNode, isHeritageClause)) {
159387
+ return void 0;
159388
+ }
159389
+ if (isSpreadElement(targetNode)) {
159390
+ return void 0;
159391
+ }
159392
+ const variableDeclaration = findAncestor(targetNode, isVariableDeclaration);
159393
+ const type = variableDeclaration && typeChecker.getTypeAtLocation(variableDeclaration);
159394
+ if (type && type.flags & 8192 /* UniqueESSymbol */) {
159395
+ return void 0;
159396
+ }
159397
+ if (!(isExpressionTarget || isShorthandPropertyAssignmentTarget))
159398
+ return void 0;
159399
+ const { typeNode, mutatedTarget } = inferType(targetNode, type);
159400
+ if (!typeNode || mutatedTarget)
159401
+ return void 0;
159402
+ if (isShorthandPropertyAssignmentTarget) {
159403
+ changeTracker.insertNodeAt(
159404
+ sourceFile,
159405
+ targetNode.end,
159406
+ createAsExpression(
159407
+ getSynthesizedDeepClone(targetNode.name),
159408
+ typeNode
159409
+ ),
159410
+ {
159411
+ prefix: ": "
159412
+ }
159413
+ );
159414
+ } else if (isExpressionTarget) {
159415
+ changeTracker.replaceNode(
159416
+ sourceFile,
159417
+ targetNode,
159418
+ createSatisfiesAsExpression(
159419
+ getSynthesizedDeepClone(targetNode),
159420
+ typeNode
159421
+ )
159422
+ );
159423
+ } else {
159424
+ Debug.assertNever(targetNode);
159425
+ }
159426
+ return [Diagnostics.Add_satisfies_and_an_inline_type_assertion_with_0, typeToStringForDiag(typeNode)];
159427
+ }
159428
+ function extractAsVariable(span) {
159429
+ const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
159430
+ const targetNode = findBestFittingNode(nodeWithDiag, span);
159431
+ if (!targetNode || isValueSignatureDeclaration(targetNode) || isValueSignatureDeclaration(targetNode.parent))
159432
+ return;
159433
+ const isExpressionTarget = isExpression(targetNode);
159434
+ if (!isExpressionTarget)
159435
+ return;
159436
+ if (isArrayLiteralExpression(targetNode)) {
159437
+ changeTracker.replaceNode(
159438
+ sourceFile,
159439
+ targetNode,
159440
+ createAsExpression(targetNode, factory.createTypeReferenceNode("const"))
159441
+ );
159442
+ return [Diagnostics.Mark_array_literal_as_const];
159443
+ }
159444
+ const parentPropertyAssignment = findAncestor(targetNode, isPropertyAssignment);
159445
+ if (parentPropertyAssignment) {
159446
+ if (parentPropertyAssignment === targetNode.parent && isEntityNameExpression(targetNode))
159447
+ return;
159448
+ const tempName = factory.createUniqueName(
159449
+ getIdentifierForNode(targetNode, sourceFile, typeChecker, sourceFile),
159450
+ 16 /* Optimistic */
159451
+ );
159452
+ let replacementTarget = targetNode;
159453
+ let initializationNode = targetNode;
159454
+ if (isSpreadElement(replacementTarget)) {
159455
+ replacementTarget = walkUpParenthesizedExpressions(replacementTarget.parent);
159456
+ if (isConstAssertion2(replacementTarget.parent)) {
159457
+ initializationNode = replacementTarget = replacementTarget.parent;
159458
+ } else {
159459
+ initializationNode = createAsExpression(
159460
+ replacementTarget,
159461
+ factory.createTypeReferenceNode("const")
159462
+ );
159463
+ }
159464
+ }
159465
+ if (isEntityNameExpression(replacementTarget))
159466
+ return void 0;
159467
+ const variableDefinition = factory.createVariableStatement(
159468
+ /*modifiers*/
159469
+ void 0,
159470
+ factory.createVariableDeclarationList([
159471
+ factory.createVariableDeclaration(
159472
+ tempName,
159473
+ /*exclamationToken*/
159474
+ void 0,
159475
+ /*type*/
159476
+ void 0,
159477
+ initializationNode
159478
+ )
159479
+ ], 2 /* Const */)
159480
+ );
159481
+ const statement = findAncestor(targetNode, isStatement);
159482
+ changeTracker.insertNodeBefore(sourceFile, statement, variableDefinition);
159483
+ changeTracker.replaceNode(
159484
+ sourceFile,
159485
+ replacementTarget,
159486
+ factory.createAsExpression(
159487
+ factory.cloneNode(tempName),
159488
+ factory.createTypeQueryNode(
159489
+ factory.cloneNode(tempName)
159490
+ )
159491
+ )
159492
+ );
159493
+ return [Diagnostics.Extract_to_variable_and_replace_with_0_as_typeof_0, typeToStringForDiag(tempName)];
159494
+ }
159495
+ }
159496
+ function findExpandoFunction(node) {
159497
+ const expandoDeclaration = findAncestor(node, (n) => isStatement(n) ? "quit" : isExpandoPropertyDeclaration(n));
159498
+ if (expandoDeclaration && isExpandoPropertyDeclaration(expandoDeclaration)) {
159499
+ let assignmentTarget = expandoDeclaration;
159500
+ if (isBinaryExpression(assignmentTarget)) {
159501
+ assignmentTarget = assignmentTarget.left;
159502
+ if (!isExpandoPropertyDeclaration(assignmentTarget))
159503
+ return void 0;
159504
+ }
159505
+ const targetType = typeChecker.getTypeAtLocation(assignmentTarget.expression);
159506
+ if (!targetType)
159507
+ return;
159508
+ const properties = typeChecker.getPropertiesOfType(targetType);
159509
+ if (some(properties, (p) => p.valueDeclaration === expandoDeclaration || p.valueDeclaration === expandoDeclaration.parent)) {
159510
+ const fn = targetType.symbol.valueDeclaration;
159511
+ if (fn) {
159512
+ if (isFunctionExpressionOrArrowFunction(fn) && isVariableDeclaration(fn.parent)) {
159513
+ return fn.parent;
159514
+ }
159515
+ if (isFunctionDeclaration(fn)) {
159516
+ return fn;
159517
+ }
159518
+ }
159519
+ }
159520
+ }
159521
+ return void 0;
159522
+ }
159523
+ function fixIsolatedDeclarationError(node) {
159524
+ if (fixedNodes == null ? void 0 : fixedNodes.has(node))
159525
+ return void 0;
159526
+ fixedNodes == null ? void 0 : fixedNodes.add(node);
159527
+ switch (node.kind) {
159528
+ case 169 /* Parameter */:
159529
+ case 172 /* PropertyDeclaration */:
159530
+ case 260 /* VariableDeclaration */:
159531
+ return addTypeToVariableLike(node);
159532
+ case 219 /* ArrowFunction */:
159533
+ case 218 /* FunctionExpression */:
159534
+ case 262 /* FunctionDeclaration */:
159535
+ case 174 /* MethodDeclaration */:
159536
+ case 177 /* GetAccessor */:
159537
+ return addTypeToSignatureDeclaration(node, sourceFile);
159538
+ case 277 /* ExportAssignment */:
159539
+ return transformExportAssignment(node);
159540
+ case 263 /* ClassDeclaration */:
159541
+ return transformExtendsClauseWithExpression(node);
159542
+ case 206 /* ObjectBindingPattern */:
159543
+ case 207 /* ArrayBindingPattern */:
159544
+ return transformDestructuringPatterns(node);
159545
+ default:
159546
+ throw new Error(`Cannot find a fix for the given node ${node.kind}`);
159547
+ }
159548
+ }
159549
+ function addTypeToSignatureDeclaration(func, sourceFile2) {
159550
+ if (func.type) {
159551
+ return;
159552
+ }
159553
+ const { typeNode } = inferType(func);
159554
+ if (typeNode) {
159555
+ changeTracker.tryInsertTypeAnnotation(
159556
+ sourceFile2,
159557
+ func,
159558
+ typeNode
159559
+ );
159560
+ return [Diagnostics.Add_return_type_0, typeToStringForDiag(typeNode)];
159561
+ }
159562
+ }
159563
+ function transformExportAssignment(defaultExport) {
159564
+ if (defaultExport.isExportEquals) {
159565
+ return;
159566
+ }
159567
+ const { typeNode } = inferType(defaultExport.expression);
159568
+ if (!typeNode)
159569
+ return void 0;
159570
+ const defaultIdentifier = factory.createUniqueName("_default");
159571
+ changeTracker.replaceNodeWithNodes(sourceFile, defaultExport, [
159572
+ factory.createVariableStatement(
159573
+ /*modifiers*/
159574
+ void 0,
159575
+ factory.createVariableDeclarationList(
159576
+ [factory.createVariableDeclaration(
159577
+ defaultIdentifier,
159578
+ /*exclamationToken*/
159579
+ void 0,
159580
+ typeNode,
159581
+ defaultExport.expression
159582
+ )],
159583
+ 2 /* Const */
159584
+ )
159585
+ ),
159586
+ factory.updateExportAssignment(defaultExport, defaultExport == null ? void 0 : defaultExport.modifiers, defaultIdentifier)
159587
+ ]);
159588
+ return [
159589
+ Diagnostics.Extract_default_export_to_variable
159590
+ ];
159591
+ }
159592
+ function transformExtendsClauseWithExpression(classDecl) {
159593
+ var _a, _b;
159594
+ const extendsClause = (_a = classDecl.heritageClauses) == null ? void 0 : _a.find((p) => p.token === 96 /* ExtendsKeyword */);
159595
+ const heritageExpression = extendsClause == null ? void 0 : extendsClause.types[0];
159596
+ if (!heritageExpression) {
159597
+ return void 0;
159598
+ }
159599
+ const { typeNode: heritageTypeNode } = inferType(heritageExpression.expression);
159600
+ if (!heritageTypeNode) {
159601
+ return void 0;
159602
+ }
159603
+ const baseClassName = factory.createUniqueName(
159604
+ classDecl.name ? classDecl.name.text + "Base" : "Anonymous",
159605
+ 16 /* Optimistic */
159606
+ );
159607
+ const heritageVariable = factory.createVariableStatement(
159608
+ /*modifiers*/
159609
+ void 0,
159610
+ factory.createVariableDeclarationList(
159611
+ [factory.createVariableDeclaration(
159612
+ baseClassName,
159613
+ /*exclamationToken*/
159614
+ void 0,
159615
+ heritageTypeNode,
159616
+ heritageExpression.expression
159617
+ )],
159618
+ 2 /* Const */
159619
+ )
159620
+ );
159621
+ changeTracker.insertNodeBefore(sourceFile, classDecl, heritageVariable);
159622
+ const trailingComments = getTrailingCommentRanges(sourceFile.text, heritageExpression.end);
159623
+ const realEnd = ((_b = trailingComments == null ? void 0 : trailingComments[trailingComments.length - 1]) == null ? void 0 : _b.end) ?? heritageExpression.end;
159624
+ changeTracker.replaceRange(
159625
+ sourceFile,
159626
+ {
159627
+ pos: heritageExpression.getFullStart(),
159628
+ end: realEnd
159629
+ },
159630
+ baseClassName,
159631
+ {
159632
+ prefix: " "
159633
+ }
159634
+ );
159635
+ return [Diagnostics.Extract_base_class_to_variable];
159636
+ }
159637
+ let ExpressionType;
159638
+ ((ExpressionType2) => {
159639
+ ExpressionType2[ExpressionType2["Text"] = 0] = "Text";
159640
+ ExpressionType2[ExpressionType2["Computed"] = 1] = "Computed";
159641
+ ExpressionType2[ExpressionType2["ArrayAccess"] = 2] = "ArrayAccess";
159642
+ ExpressionType2[ExpressionType2["Identifier"] = 3] = "Identifier";
159643
+ })(ExpressionType || (ExpressionType = {}));
159644
+ function transformDestructuringPatterns(bindingPattern) {
159645
+ var _a;
159646
+ const enclosingVariableDeclaration = bindingPattern.parent;
159647
+ const enclosingVarStmt = bindingPattern.parent.parent.parent;
159648
+ if (!enclosingVariableDeclaration.initializer)
159649
+ return void 0;
159650
+ let baseExpr;
159651
+ const newNodes = [];
159652
+ if (!isIdentifier(enclosingVariableDeclaration.initializer)) {
159653
+ const tempHolderForReturn = factory.createUniqueName("dest", 16 /* Optimistic */);
159654
+ baseExpr = { expression: { kind: 3 /* Identifier */, identifier: tempHolderForReturn } };
159655
+ newNodes.push(factory.createVariableStatement(
159656
+ /*modifiers*/
159657
+ void 0,
159658
+ factory.createVariableDeclarationList(
159659
+ [factory.createVariableDeclaration(
159660
+ tempHolderForReturn,
159661
+ /*exclamationToken*/
159662
+ void 0,
159663
+ /*type*/
159664
+ void 0,
159665
+ enclosingVariableDeclaration.initializer
159666
+ )],
159667
+ 2 /* Const */
159668
+ )
159669
+ ));
159670
+ } else {
159671
+ baseExpr = { expression: { kind: 3 /* Identifier */, identifier: enclosingVariableDeclaration.initializer } };
159672
+ }
159673
+ const bindingElements = [];
159674
+ if (isArrayBindingPattern(bindingPattern)) {
159675
+ addArrayBindingPatterns(bindingPattern, bindingElements, baseExpr);
159676
+ } else {
159677
+ addObjectBindingPatterns(bindingPattern, bindingElements, baseExpr);
159678
+ }
159679
+ const expressionToVar = /* @__PURE__ */ new Map();
159680
+ for (const bindingElement of bindingElements) {
159681
+ if (bindingElement.element.propertyName && isComputedPropertyName(bindingElement.element.propertyName)) {
159682
+ const computedExpression = bindingElement.element.propertyName.expression;
159683
+ const identifierForComputedProperty = factory.getGeneratedNameForNode(computedExpression);
159684
+ const variableDecl = factory.createVariableDeclaration(
159685
+ identifierForComputedProperty,
159686
+ /*exclamationToken*/
159687
+ void 0,
159688
+ /*type*/
159689
+ void 0,
159690
+ computedExpression
159691
+ );
159692
+ const variableList = factory.createVariableDeclarationList([variableDecl], 2 /* Const */);
159693
+ const variableStatement = factory.createVariableStatement(
159694
+ /*modifiers*/
159695
+ void 0,
159696
+ variableList
159697
+ );
159698
+ newNodes.push(variableStatement);
159699
+ expressionToVar.set(computedExpression, identifierForComputedProperty);
159700
+ }
159701
+ const name = bindingElement.element.name;
159702
+ if (isArrayBindingPattern(name)) {
159703
+ addArrayBindingPatterns(name, bindingElements, bindingElement);
159704
+ } else if (isObjectBindingPattern(name)) {
159705
+ addObjectBindingPatterns(name, bindingElements, bindingElement);
159706
+ } else {
159707
+ const { typeNode } = inferType(name);
159708
+ let variableInitializer = createChainedExpression(bindingElement, expressionToVar);
159709
+ if (bindingElement.element.initializer) {
159710
+ const propertyName = (_a = bindingElement.element) == null ? void 0 : _a.propertyName;
159711
+ const tempName = factory.createUniqueName(
159712
+ propertyName && isIdentifier(propertyName) ? propertyName.text : "temp",
159713
+ 16 /* Optimistic */
159714
+ );
159715
+ newNodes.push(factory.createVariableStatement(
159716
+ /*modifiers*/
159717
+ void 0,
159718
+ factory.createVariableDeclarationList(
159719
+ [factory.createVariableDeclaration(
159720
+ tempName,
159721
+ /*exclamationToken*/
159722
+ void 0,
159723
+ /*type*/
159724
+ void 0,
159725
+ variableInitializer
159726
+ )],
159727
+ 2 /* Const */
159728
+ )
159729
+ ));
159730
+ variableInitializer = factory.createConditionalExpression(
159731
+ factory.createBinaryExpression(
159732
+ tempName,
159733
+ factory.createToken(37 /* EqualsEqualsEqualsToken */),
159734
+ factory.createIdentifier("undefined")
159735
+ ),
159736
+ factory.createToken(58 /* QuestionToken */),
159737
+ bindingElement.element.initializer,
159738
+ factory.createToken(59 /* ColonToken */),
159739
+ variableInitializer
159740
+ );
159741
+ }
159742
+ const exportModifier = hasSyntacticModifier(enclosingVarStmt, 32 /* Export */) ? [factory.createToken(95 /* ExportKeyword */)] : void 0;
159743
+ newNodes.push(factory.createVariableStatement(
159744
+ exportModifier,
159745
+ factory.createVariableDeclarationList(
159746
+ [factory.createVariableDeclaration(
159747
+ name,
159748
+ /*exclamationToken*/
159749
+ void 0,
159750
+ typeNode,
159751
+ variableInitializer
159752
+ )],
159753
+ 2 /* Const */
159754
+ )
159755
+ ));
159756
+ }
159757
+ }
159758
+ if (enclosingVarStmt.declarationList.declarations.length > 1) {
159759
+ newNodes.push(factory.updateVariableStatement(
159760
+ enclosingVarStmt,
159761
+ enclosingVarStmt.modifiers,
159762
+ factory.updateVariableDeclarationList(
159763
+ enclosingVarStmt.declarationList,
159764
+ enclosingVarStmt.declarationList.declarations.filter((node) => node !== bindingPattern.parent)
159765
+ )
159766
+ ));
159767
+ }
159768
+ changeTracker.replaceNodeWithNodes(sourceFile, enclosingVarStmt, newNodes);
159769
+ return [
159770
+ Diagnostics.Extract_binding_expressions_to_variable
159771
+ ];
159772
+ }
159773
+ function addArrayBindingPatterns(bindingPattern, bindingElements, parent2) {
159774
+ for (let i = 0; i < bindingPattern.elements.length; ++i) {
159775
+ const element = bindingPattern.elements[i];
159776
+ if (isOmittedExpression(element)) {
159777
+ continue;
159778
+ }
159779
+ bindingElements.push({
159780
+ element,
159781
+ parent: parent2,
159782
+ expression: { kind: 2 /* ArrayAccess */, arrayIndex: i }
159783
+ });
159784
+ }
159785
+ }
159786
+ function addObjectBindingPatterns(bindingPattern, bindingElements, parent2) {
159787
+ for (const bindingElement of bindingPattern.elements) {
159788
+ let name;
159789
+ if (bindingElement.propertyName) {
159790
+ if (isComputedPropertyName(bindingElement.propertyName)) {
159791
+ bindingElements.push({
159792
+ element: bindingElement,
159793
+ parent: parent2,
159794
+ expression: { kind: 1 /* Computed */, computed: bindingElement.propertyName.expression }
159795
+ });
159796
+ continue;
159797
+ } else {
159798
+ name = bindingElement.propertyName.text;
159799
+ }
159800
+ } else {
159801
+ name = bindingElement.name.text;
159802
+ }
159803
+ bindingElements.push({
159804
+ element: bindingElement,
159805
+ parent: parent2,
159806
+ expression: { kind: 0 /* Text */, text: name }
159807
+ });
159808
+ }
159809
+ }
159810
+ function createChainedExpression(expression, expressionToVar) {
159811
+ const reverseTraverse = [expression];
159812
+ while (expression.parent) {
159813
+ expression = expression.parent;
159814
+ reverseTraverse.push(expression);
159815
+ }
159816
+ let chainedExpression = reverseTraverse[reverseTraverse.length - 1].expression.identifier;
159817
+ for (let i = reverseTraverse.length - 2; i >= 0; --i) {
159818
+ const nextSubExpr = reverseTraverse[i].expression;
159819
+ if (nextSubExpr.kind === 0 /* Text */) {
159820
+ chainedExpression = factory.createPropertyAccessChain(
159821
+ chainedExpression,
159822
+ /*questionDotToken*/
159823
+ void 0,
159824
+ factory.createIdentifier(nextSubExpr.text)
159825
+ );
159826
+ } else if (nextSubExpr.kind === 1 /* Computed */) {
159827
+ chainedExpression = factory.createElementAccessExpression(
159828
+ chainedExpression,
159829
+ expressionToVar.get(nextSubExpr.computed)
159830
+ );
159831
+ } else if (nextSubExpr.kind === 2 /* ArrayAccess */) {
159832
+ chainedExpression = factory.createElementAccessExpression(
159833
+ chainedExpression,
159834
+ nextSubExpr.arrayIndex
159835
+ );
159836
+ }
159837
+ }
159838
+ return chainedExpression;
159839
+ }
159840
+ function inferType(node, variableType) {
159841
+ if (typePrintMode === 1 /* Relative */) {
159842
+ return relativeType(node);
159843
+ }
159844
+ let type = isValueSignatureDeclaration(node) ? tryGetReturnType2(node) : typeChecker.getTypeAtLocation(node);
159845
+ if (!type) {
159846
+ return emptyInferenceResult;
159847
+ }
159848
+ if (typePrintMode === 2 /* Widened */) {
159849
+ if (variableType) {
159850
+ type = variableType;
159851
+ }
159852
+ const widenedType = typeChecker.getWidenedLiteralType(type);
159853
+ if (typeChecker.isTypeAssignableTo(widenedType, type)) {
159854
+ return emptyInferenceResult;
159855
+ }
159856
+ type = widenedType;
159857
+ }
159858
+ if (isParameter(node) && emitResolver.requiresAddingImplicitUndefined(node)) {
159859
+ type = typeChecker.getUnionType([typeChecker.getUndefinedType(), type], 0 /* None */);
159860
+ }
159861
+ const flags = (isVariableDeclaration(node) || isPropertyDeclaration(node) && hasSyntacticModifier(node, 256 /* Static */ | 8 /* Readonly */)) && type.flags & 8192 /* UniqueESSymbol */ ? 1048576 /* AllowUniqueESSymbolType */ : 0 /* None */;
159862
+ return {
159863
+ typeNode: typeToTypeNode2(type, findAncestor(node, isDeclaration) ?? sourceFile, flags),
159864
+ mutatedTarget: false
159865
+ };
159866
+ }
159867
+ function createTypeOfFromEntityNameExpression(node) {
159868
+ return factory.createTypeQueryNode(getSynthesizedDeepClone(node));
159869
+ }
159870
+ function typeFromArraySpreadElements(node, name = "temp") {
159871
+ const isConstContext = !!findAncestor(node, isConstAssertion2);
159872
+ if (!isConstContext)
159873
+ return emptyInferenceResult;
159874
+ return typeFromSpreads(
159875
+ node,
159876
+ name,
159877
+ isConstContext,
159878
+ (n) => n.elements,
159879
+ isSpreadElement,
159880
+ factory.createSpreadElement,
159881
+ (props) => factory.createArrayLiteralExpression(
159882
+ props,
159883
+ /*multiLine*/
159884
+ true
159885
+ ),
159886
+ (types) => factory.createTupleTypeNode(types.map(factory.createRestTypeNode))
159887
+ );
159888
+ }
159889
+ function typeFromObjectSpreadAssignment(node, name = "temp") {
159890
+ const isConstContext = !!findAncestor(node, isConstAssertion2);
159891
+ return typeFromSpreads(
159892
+ node,
159893
+ name,
159894
+ isConstContext,
159895
+ (n) => n.properties,
159896
+ isSpreadAssignment,
159897
+ factory.createSpreadAssignment,
159898
+ (props) => factory.createObjectLiteralExpression(
159899
+ props,
159900
+ /*multiLine*/
159901
+ true
159902
+ ),
159903
+ factory.createIntersectionTypeNode
159904
+ );
159905
+ }
159906
+ function typeFromSpreads(node, name, isConstContext, getChildren, isSpread, createSpread, makeNodeOfKind, finalType) {
159907
+ const intersectionTypes = [];
159908
+ const newSpreads = [];
159909
+ let currentVariableProperties;
159910
+ const statement = findAncestor(node, isStatement);
159911
+ for (const prop of getChildren(node)) {
159912
+ if (isSpread(prop)) {
159913
+ finalizesVariablePart();
159914
+ if (isEntityNameExpression(prop.expression)) {
159915
+ intersectionTypes.push(createTypeOfFromEntityNameExpression(prop.expression));
159916
+ newSpreads.push(prop);
159917
+ } else {
159918
+ makeVariable(prop.expression);
159919
+ }
159920
+ } else {
159921
+ (currentVariableProperties ?? (currentVariableProperties = [])).push(prop);
159922
+ }
159923
+ }
159924
+ if (newSpreads.length === 0) {
159925
+ return emptyInferenceResult;
159926
+ }
159927
+ finalizesVariablePart();
159928
+ changeTracker.replaceNode(sourceFile, node, makeNodeOfKind(newSpreads));
159929
+ return {
159930
+ typeNode: finalType(intersectionTypes),
159931
+ mutatedTarget: true
159932
+ };
159933
+ function makeVariable(expression) {
159934
+ const tempName = factory.createUniqueName(
159935
+ name + "_Part" + (newSpreads.length + 1),
159936
+ 16 /* Optimistic */
159937
+ );
159938
+ const initializer = !isConstContext ? expression : factory.createAsExpression(
159939
+ expression,
159940
+ factory.createTypeReferenceNode("const")
159941
+ );
159942
+ const variableDefinition = factory.createVariableStatement(
159943
+ /*modifiers*/
159944
+ void 0,
159945
+ factory.createVariableDeclarationList([
159946
+ factory.createVariableDeclaration(
159947
+ tempName,
159948
+ /*exclamationToken*/
159949
+ void 0,
159950
+ /*type*/
159951
+ void 0,
159952
+ initializer
159953
+ )
159954
+ ], 2 /* Const */)
159955
+ );
159956
+ changeTracker.insertNodeBefore(sourceFile, statement, variableDefinition);
159957
+ intersectionTypes.push(createTypeOfFromEntityNameExpression(tempName));
159958
+ newSpreads.push(createSpread(tempName));
159959
+ }
159960
+ function finalizesVariablePart() {
159961
+ if (currentVariableProperties) {
159962
+ makeVariable(makeNodeOfKind(
159963
+ currentVariableProperties
159964
+ ));
159965
+ currentVariableProperties = void 0;
159966
+ }
159967
+ }
159968
+ }
159969
+ function isConstAssertion2(location) {
159970
+ return isAssertionExpression(location) && isConstTypeReference(location.type);
159971
+ }
159972
+ function relativeType(node) {
159973
+ if (isParameter(node)) {
159974
+ return emptyInferenceResult;
159975
+ }
159976
+ if (isShorthandPropertyAssignment(node)) {
159977
+ return {
159978
+ typeNode: createTypeOfFromEntityNameExpression(node.name),
159979
+ mutatedTarget: false
159980
+ };
159981
+ }
159982
+ if (isEntityNameExpression(node)) {
159983
+ return {
159984
+ typeNode: createTypeOfFromEntityNameExpression(node),
159985
+ mutatedTarget: false
159986
+ };
159987
+ }
159988
+ if (isConstAssertion2(node)) {
159989
+ return relativeType(node.expression);
159990
+ }
159991
+ if (isArrayLiteralExpression(node)) {
159992
+ const variableDecl = findAncestor(node, isVariableDeclaration);
159993
+ const partName = variableDecl && isIdentifier(variableDecl.name) ? variableDecl.name.text : void 0;
159994
+ return typeFromArraySpreadElements(node, partName);
159995
+ }
159996
+ if (isObjectLiteralExpression(node)) {
159997
+ const variableDecl = findAncestor(node, isVariableDeclaration);
159998
+ const partName = variableDecl && isIdentifier(variableDecl.name) ? variableDecl.name.text : void 0;
159999
+ return typeFromObjectSpreadAssignment(node, partName);
160000
+ }
160001
+ if (isVariableDeclaration(node) && node.initializer) {
160002
+ return relativeType(node.initializer);
160003
+ }
160004
+ if (isConditionalExpression(node)) {
160005
+ const { typeNode: trueType, mutatedTarget: mTrue } = relativeType(node.whenTrue);
160006
+ if (!trueType)
160007
+ return emptyInferenceResult;
160008
+ const { typeNode: falseType, mutatedTarget: mFalse } = relativeType(node.whenFalse);
160009
+ if (!falseType)
160010
+ return emptyInferenceResult;
160011
+ return {
160012
+ typeNode: factory.createUnionTypeNode([trueType, falseType]),
160013
+ mutatedTarget: mTrue || mFalse
160014
+ };
160015
+ }
160016
+ return emptyInferenceResult;
160017
+ }
160018
+ function typeToTypeNode2(type, enclosingDeclaration, flags = 0 /* None */) {
160019
+ let isTruncated = false;
160020
+ const result2 = typeToAutoImportableTypeNode(typeChecker, importAdder, type, enclosingDeclaration, scriptTarget, declarationEmitNodeBuilderFlags2 | flags, {
160021
+ moduleResolverHost: program,
160022
+ trackSymbol() {
160023
+ return true;
160024
+ },
160025
+ reportTruncationError() {
160026
+ isTruncated = true;
160027
+ }
160028
+ });
160029
+ return isTruncated ? factory.createKeywordTypeNode(133 /* AnyKeyword */) : result2;
160030
+ }
160031
+ function tryGetReturnType2(node) {
160032
+ const signature = typeChecker.getSignatureFromDeclaration(node);
160033
+ if (signature) {
160034
+ return typeChecker.getReturnTypeOfSignature(signature);
160035
+ }
160036
+ }
160037
+ function addTypeToVariableLike(decl) {
160038
+ const { typeNode } = inferType(decl);
160039
+ if (typeNode) {
160040
+ if (decl.type) {
160041
+ changeTracker.replaceNode(getSourceFileOfNode(decl), decl.type, typeNode);
160042
+ } else {
160043
+ changeTracker.tryInsertTypeAnnotation(getSourceFileOfNode(decl), decl, typeNode);
160044
+ }
160045
+ return [Diagnostics.Add_annotation_of_type_0, typeToStringForDiag(typeNode)];
160046
+ }
160047
+ }
160048
+ function typeToStringForDiag(node) {
160049
+ setEmitFlags(node, 1 /* SingleLine */);
160050
+ const result2 = typePrinter.printNode(4 /* Unspecified */, node, sourceFile);
160051
+ if (result2.length > defaultMaximumTruncationLength) {
160052
+ return result2.substring(0, defaultMaximumTruncationLength - "...".length) + "...";
160053
+ }
160054
+ setEmitFlags(node, 0 /* None */);
160055
+ return result2;
160056
+ }
160057
+ }
160058
+ function findAncestorWithMissingType(node) {
160059
+ return findAncestor(node, (n) => {
160060
+ return canHaveTypeAnnotation.has(n.kind) && (!isObjectBindingPattern(n) && !isArrayBindingPattern(n) || isVariableDeclaration(n.parent));
160061
+ });
160062
+ }
160063
+ function findBestFittingNode(node, span) {
160064
+ while (node && node.end < span.start + span.length) {
160065
+ node = node.parent;
160066
+ }
160067
+ while (node.parent.pos === node.pos && node.parent.end === node.end) {
160068
+ node = node.parent;
160069
+ }
160070
+ if (isIdentifier(node) && hasInitializer(node.parent) && node.parent.initializer) {
160071
+ return node.parent.initializer;
160072
+ }
160073
+ return node;
160074
+ }
160075
+
160076
+ // src/services/codefixes/fixAwaitInSyncFunction.ts
160077
+ var fixId37 = "fixAwaitInSyncFunction";
160078
+ var errorCodes48 = [
159080
160079
  Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
159081
160080
  Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
159082
160081
  Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
159083
160082
  Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
159084
160083
  ];
159085
160084
  registerCodeFix({
159086
- errorCodes: errorCodes47,
160085
+ errorCodes: errorCodes48,
159087
160086
  getCodeActions(context) {
159088
160087
  const { sourceFile, span } = context;
159089
160088
  const nodes = getNodes3(sourceFile, span.start);
159090
160089
  if (!nodes)
159091
160090
  return void 0;
159092
160091
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, nodes));
159093
- return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
160092
+ return [createCodeFixAction(fixId37, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId37, Diagnostics.Add_all_missing_async_modifiers)];
159094
160093
  },
159095
- fixIds: [fixId36],
160094
+ fixIds: [fixId37],
159096
160095
  getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
159097
160096
  const seen = /* @__PURE__ */ new Map();
159098
- return codeFixAll(context, errorCodes47, (changes, diag2) => {
160097
+ return codeFixAll(context, errorCodes48, (changes, diag2) => {
159099
160098
  const nodes = getNodes3(diag2.file, diag2.start);
159100
160099
  if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
159101
160100
  return;
@@ -159149,21 +160148,21 @@ function doChange31(changes, sourceFile, { insertBefore, returnType }) {
159149
160148
  }
159150
160149
 
159151
160150
  // src/services/codefixes/fixPropertyOverrideAccessor.ts
159152
- var errorCodes48 = [
160151
+ var errorCodes49 = [
159153
160152
  Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
159154
160153
  Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
159155
160154
  ];
159156
- var fixId37 = "fixPropertyOverrideAccessor";
160155
+ var fixId38 = "fixPropertyOverrideAccessor";
159157
160156
  registerCodeFix({
159158
- errorCodes: errorCodes48,
160157
+ errorCodes: errorCodes49,
159159
160158
  getCodeActions(context) {
159160
160159
  const edits = doChange32(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
159161
160160
  if (edits) {
159162
- return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
160161
+ return [createCodeFixAction(fixId38, edits, Diagnostics.Generate_get_and_set_accessors, fixId38, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
159163
160162
  }
159164
160163
  },
159165
- fixIds: [fixId37],
159166
- getAllCodeActions: (context) => codeFixAll(context, errorCodes48, (changes, diag2) => {
160164
+ fixIds: [fixId38],
160165
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes49, (changes, diag2) => {
159167
160166
  const edits = doChange32(diag2.file, diag2.start, diag2.length, diag2.code, context);
159168
160167
  if (edits) {
159169
160168
  for (const edit of edits) {
@@ -159201,8 +160200,8 @@ function doChange32(file, start, length2, code, context) {
159201
160200
  }
159202
160201
 
159203
160202
  // src/services/codefixes/inferFromUsage.ts
159204
- var fixId38 = "inferFromUsage";
159205
- var errorCodes49 = [
160203
+ var fixId39 = "inferFromUsage";
160204
+ var errorCodes50 = [
159206
160205
  // Variable declarations
159207
160206
  Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
159208
160207
  // Variable uses
@@ -159236,7 +160235,7 @@ var errorCodes49 = [
159236
160235
  Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
159237
160236
  ];
159238
160237
  registerCodeFix({
159239
- errorCodes: errorCodes49,
160238
+ errorCodes: errorCodes50,
159240
160239
  getCodeActions(context) {
159241
160240
  const { sourceFile, program, span: { start }, errorCode, cancellationToken, host, preferences } = context;
159242
160241
  const token = getTokenAtPosition(sourceFile, start);
@@ -159256,13 +160255,13 @@ registerCodeFix({
159256
160255
  );
159257
160256
  });
159258
160257
  const name = declaration && getNameOfDeclaration(declaration);
159259
- return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId38, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId38, Diagnostics.Infer_all_types_from_usage)];
160258
+ return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId39, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId39, Diagnostics.Infer_all_types_from_usage)];
159260
160259
  },
159261
- fixIds: [fixId38],
160260
+ fixIds: [fixId39],
159262
160261
  getAllCodeActions(context) {
159263
160262
  const { sourceFile, program, cancellationToken, host, preferences } = context;
159264
160263
  const markSeen = nodeSeenTracker();
159265
- return codeFixAll(context, errorCodes49, (changes, err) => {
160264
+ return codeFixAll(context, errorCodes50, (changes, err) => {
159266
160265
  doChange33(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
159267
160266
  });
159268
160267
  }
@@ -160201,13 +161200,13 @@ function inferTypeFromReferences(program, references, cancellationToken) {
160201
161200
  }
160202
161201
 
160203
161202
  // src/services/codefixes/fixReturnTypeInAsyncFunction.ts
160204
- var fixId39 = "fixReturnTypeInAsyncFunction";
160205
- var errorCodes50 = [
161203
+ var fixId40 = "fixReturnTypeInAsyncFunction";
161204
+ var errorCodes51 = [
160206
161205
  Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code
160207
161206
  ];
160208
161207
  registerCodeFix({
160209
- errorCodes: errorCodes50,
160210
- fixIds: [fixId39],
161208
+ errorCodes: errorCodes51,
161209
+ fixIds: [fixId40],
160211
161210
  getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
160212
161211
  const { sourceFile, program, span } = context;
160213
161212
  const checker = program.getTypeChecker();
@@ -160218,14 +161217,14 @@ registerCodeFix({
160218
161217
  const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
160219
161218
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(t, sourceFile, returnTypeNode, promisedTypeNode));
160220
161219
  return [createCodeFixAction(
160221
- fixId39,
161220
+ fixId40,
160222
161221
  changes,
160223
161222
  [Diagnostics.Replace_0_with_Promise_1, checker.typeToString(returnType), checker.typeToString(promisedType)],
160224
- fixId39,
161223
+ fixId40,
160225
161224
  Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
160226
161225
  )];
160227
161226
  },
160228
- getAllCodeActions: (context) => codeFixAll(context, errorCodes50, (changes, diag2) => {
161227
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes51, (changes, diag2) => {
160229
161228
  const info = getInfo16(diag2.file, context.program.getTypeChecker(), diag2.start);
160230
161229
  if (info) {
160231
161230
  doChange34(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
@@ -160261,13 +161260,13 @@ function doChange34(changes, sourceFile, returnTypeNode, promisedTypeNode) {
160261
161260
 
160262
161261
  // src/services/codefixes/disableJsDiagnostics.ts
160263
161262
  var fixName4 = "disableJsDiagnostics";
160264
- var fixId40 = "disableJsDiagnostics";
160265
- var errorCodes51 = mapDefined(Object.keys(Diagnostics), (key) => {
161263
+ var fixId41 = "disableJsDiagnostics";
161264
+ var errorCodes52 = mapDefined(Object.keys(Diagnostics), (key) => {
160266
161265
  const diag2 = Diagnostics[key];
160267
161266
  return diag2.category === 1 /* Error */ ? diag2.code : void 0;
160268
161267
  });
160269
161268
  registerCodeFix({
160270
- errorCodes: errorCodes51,
161269
+ errorCodes: errorCodes52,
160271
161270
  getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
160272
161271
  const { sourceFile, program, span, host, formatContext } = context;
160273
161272
  if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
@@ -160288,14 +161287,14 @@ registerCodeFix({
160288
161287
  )
160289
161288
  ];
160290
161289
  if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
160291
- fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message, fixId40, Diagnostics.Add_ts_ignore_to_all_error_messages));
161290
+ fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message, fixId41, Diagnostics.Add_ts_ignore_to_all_error_messages));
160292
161291
  }
160293
161292
  return fixes;
160294
161293
  },
160295
- fixIds: [fixId40],
161294
+ fixIds: [fixId41],
160296
161295
  getAllCodeActions: (context) => {
160297
161296
  const seenLines = /* @__PURE__ */ new Set();
160298
- return codeFixAll(context, errorCodes51, (changes, diag2) => {
161297
+ return codeFixAll(context, errorCodes52, (changes, diag2) => {
160299
161298
  if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
160300
161299
  makeChange8(changes, diag2.file, diag2.start, seenLines);
160301
161300
  }
@@ -161294,9 +162293,9 @@ var fixName6 = "strictClassInitialization";
161294
162293
  var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
161295
162294
  var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
161296
162295
  var fixIdAddInitializer = "addMissingPropertyInitializer";
161297
- var errorCodes52 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
162296
+ var errorCodes53 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
161298
162297
  registerCodeFix({
161299
- errorCodes: errorCodes52,
162298
+ errorCodes: errorCodes53,
161300
162299
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
161301
162300
  const info = getInfo17(context.sourceFile, context.span.start);
161302
162301
  if (!info)
@@ -161309,7 +162308,7 @@ registerCodeFix({
161309
162308
  },
161310
162309
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
161311
162310
  getAllCodeActions: (context) => {
161312
- return codeFixAll(context, errorCodes52, (changes, diag2) => {
162311
+ return codeFixAll(context, errorCodes53, (changes, diag2) => {
161313
162312
  const info = getInfo17(diag2.file, diag2.start);
161314
162313
  if (!info)
161315
162314
  return;
@@ -161439,20 +162438,20 @@ function getDefaultValueFromType(checker, type) {
161439
162438
  }
161440
162439
 
161441
162440
  // src/services/codefixes/requireInTs.ts
161442
- var fixId41 = "requireInTs";
161443
- var errorCodes53 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
162441
+ var fixId42 = "requireInTs";
162442
+ var errorCodes54 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
161444
162443
  registerCodeFix({
161445
- errorCodes: errorCodes53,
162444
+ errorCodes: errorCodes54,
161446
162445
  getCodeActions(context) {
161447
162446
  const info = getInfo18(context.sourceFile, context.program, context.span.start);
161448
162447
  if (!info) {
161449
162448
  return void 0;
161450
162449
  }
161451
162450
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(t, context.sourceFile, info));
161452
- return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
162451
+ return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_require_to_import, fixId42, Diagnostics.Convert_all_require_to_import)];
161453
162452
  },
161454
- fixIds: [fixId41],
161455
- getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
162453
+ fixIds: [fixId42],
162454
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
161456
162455
  const info = getInfo18(diag2.file, context.program, diag2.start);
161457
162456
  if (info) {
161458
162457
  doChange35(changes, context.sourceFile, info);
@@ -161527,20 +162526,20 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
161527
162526
  }
161528
162527
 
161529
162528
  // src/services/codefixes/useDefaultImport.ts
161530
- var fixId42 = "useDefaultImport";
161531
- var errorCodes54 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
162529
+ var fixId43 = "useDefaultImport";
162530
+ var errorCodes55 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
161532
162531
  registerCodeFix({
161533
- errorCodes: errorCodes54,
162532
+ errorCodes: errorCodes55,
161534
162533
  getCodeActions(context) {
161535
162534
  const { sourceFile, span: { start } } = context;
161536
162535
  const info = getInfo19(sourceFile, start);
161537
162536
  if (!info)
161538
162537
  return void 0;
161539
162538
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(t, sourceFile, info, context.preferences));
161540
- return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
162539
+ return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_default_import, fixId43, Diagnostics.Convert_all_to_default_imports)];
161541
162540
  },
161542
- fixIds: [fixId42],
161543
- getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
162541
+ fixIds: [fixId43],
162542
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => {
161544
162543
  const info = getInfo19(diag2.file, diag2.start);
161545
162544
  if (info)
161546
162545
  doChange36(changes, diag2.file, info, context.preferences);
@@ -161569,21 +162568,21 @@ function doChange36(changes, sourceFile, info, preferences) {
161569
162568
  }
161570
162569
 
161571
162570
  // src/services/codefixes/useBigintLiteral.ts
161572
- var fixId43 = "useBigintLiteral";
161573
- var errorCodes55 = [
162571
+ var fixId44 = "useBigintLiteral";
162572
+ var errorCodes56 = [
161574
162573
  Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
161575
162574
  ];
161576
162575
  registerCodeFix({
161577
- errorCodes: errorCodes55,
162576
+ errorCodes: errorCodes56,
161578
162577
  getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
161579
162578
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
161580
162579
  if (changes.length > 0) {
161581
- return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId43, Diagnostics.Convert_all_to_bigint_numeric_literals)];
162580
+ return [createCodeFixAction(fixId44, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId44, Diagnostics.Convert_all_to_bigint_numeric_literals)];
161582
162581
  }
161583
162582
  },
161584
- fixIds: [fixId43],
162583
+ fixIds: [fixId44],
161585
162584
  getAllCodeActions: (context) => {
161586
- return codeFixAll(context, errorCodes55, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
162585
+ return codeFixAll(context, errorCodes56, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
161587
162586
  }
161588
162587
  });
161589
162588
  function makeChange9(changeTracker, sourceFile, span) {
@@ -161597,18 +162596,18 @@ function makeChange9(changeTracker, sourceFile, span) {
161597
162596
 
161598
162597
  // src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
161599
162598
  var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
161600
- var fixId44 = fixIdAddMissingTypeof;
161601
- var errorCodes56 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
162599
+ var fixId45 = fixIdAddMissingTypeof;
162600
+ var errorCodes57 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
161602
162601
  registerCodeFix({
161603
- errorCodes: errorCodes56,
162602
+ errorCodes: errorCodes57,
161604
162603
  getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
161605
162604
  const { sourceFile, span } = context;
161606
162605
  const importType = getImportTypeNode(sourceFile, span.start);
161607
162606
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(t, sourceFile, importType));
161608
- return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
162607
+ return [createCodeFixAction(fixId45, changes, Diagnostics.Add_missing_typeof, fixId45, Diagnostics.Add_missing_typeof)];
161609
162608
  },
161610
- fixIds: [fixId44],
161611
- getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
162609
+ fixIds: [fixId45],
162610
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
161612
162611
  });
161613
162612
  function getImportTypeNode(sourceFile, pos) {
161614
162613
  const token = getTokenAtPosition(sourceFile, pos);
@@ -161631,9 +162630,9 @@ function doChange37(changes, sourceFile, importType) {
161631
162630
 
161632
162631
  // src/services/codefixes/wrapJsxInFragment.ts
161633
162632
  var fixID2 = "wrapJsxInFragment";
161634
- var errorCodes57 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
162633
+ var errorCodes58 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
161635
162634
  registerCodeFix({
161636
- errorCodes: errorCodes57,
162635
+ errorCodes: errorCodes58,
161637
162636
  getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
161638
162637
  const { sourceFile, span } = context;
161639
162638
  const node = findNodeToFix(sourceFile, span.start);
@@ -161643,7 +162642,7 @@ registerCodeFix({
161643
162642
  return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
161644
162643
  },
161645
162644
  fixIds: [fixID2],
161646
- getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
162645
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => {
161647
162646
  const node = findNodeToFix(context.sourceFile, diag2.start);
161648
162647
  if (!node)
161649
162648
  return void 0;
@@ -161688,16 +162687,16 @@ function flattenInvalidBinaryExpr(node) {
161688
162687
  }
161689
162688
 
161690
162689
  // src/services/codefixes/wrapDecoratorInParentheses.ts
161691
- var fixId45 = "wrapDecoratorInParentheses";
161692
- var errorCodes58 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
162690
+ var fixId46 = "wrapDecoratorInParentheses";
162691
+ var errorCodes59 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
161693
162692
  registerCodeFix({
161694
- errorCodes: errorCodes58,
162693
+ errorCodes: errorCodes59,
161695
162694
  getCodeActions: function getCodeActionsToWrapDecoratorExpressionInParentheses(context) {
161696
162695
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span.start));
161697
- return [createCodeFixAction(fixId45, changes, Diagnostics.Wrap_in_parentheses, fixId45, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
162696
+ return [createCodeFixAction(fixId46, changes, Diagnostics.Wrap_in_parentheses, fixId46, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
161698
162697
  },
161699
- fixIds: [fixId45],
161700
- getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => makeChange10(changes, diag2.file, diag2.start))
162698
+ fixIds: [fixId46],
162699
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => makeChange10(changes, diag2.file, diag2.start))
161701
162700
  });
161702
162701
  function makeChange10(changeTracker, sourceFile, pos) {
161703
162702
  const token = getTokenAtPosition(sourceFile, pos);
@@ -161708,10 +162707,10 @@ function makeChange10(changeTracker, sourceFile, pos) {
161708
162707
  }
161709
162708
 
161710
162709
  // src/services/codefixes/convertToMappedObjectType.ts
161711
- var fixId46 = "fixConvertToMappedObjectType";
161712
- var errorCodes59 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
162710
+ var fixId47 = "fixConvertToMappedObjectType";
162711
+ var errorCodes60 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
161713
162712
  registerCodeFix({
161714
- errorCodes: errorCodes59,
162713
+ errorCodes: errorCodes60,
161715
162714
  getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
161716
162715
  const { sourceFile, span } = context;
161717
162716
  const info = getInfo20(sourceFile, span.start);
@@ -161719,10 +162718,10 @@ registerCodeFix({
161719
162718
  return void 0;
161720
162719
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
161721
162720
  const name = idText(info.container.name);
161722
- return [createCodeFixAction(fixId46, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId46, [Diagnostics.Convert_0_to_mapped_object_type, name])];
162721
+ return [createCodeFixAction(fixId47, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId47, [Diagnostics.Convert_0_to_mapped_object_type, name])];
161723
162722
  },
161724
- fixIds: [fixId46],
161725
- getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
162723
+ fixIds: [fixId47],
162724
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, diag2) => {
161726
162725
  const info = getInfo20(diag2.file, diag2.start);
161727
162726
  if (info)
161728
162727
  doChange39(changes, diag2.file, info);
@@ -161770,12 +162769,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
161770
162769
  }
161771
162770
 
161772
162771
  // src/services/codefixes/removeAccidentalCallParentheses.ts
161773
- var fixId47 = "removeAccidentalCallParentheses";
161774
- var errorCodes60 = [
162772
+ var fixId48 = "removeAccidentalCallParentheses";
162773
+ var errorCodes61 = [
161775
162774
  Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
161776
162775
  ];
161777
162776
  registerCodeFix({
161778
- errorCodes: errorCodes60,
162777
+ errorCodes: errorCodes61,
161779
162778
  getCodeActions(context) {
161780
162779
  const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
161781
162780
  if (!callExpression) {
@@ -161784,27 +162783,27 @@ registerCodeFix({
161784
162783
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
161785
162784
  t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
161786
162785
  });
161787
- return [createCodeFixActionWithoutFixAll(fixId47, changes, Diagnostics.Remove_parentheses)];
162786
+ return [createCodeFixActionWithoutFixAll(fixId48, changes, Diagnostics.Remove_parentheses)];
161788
162787
  },
161789
- fixIds: [fixId47]
162788
+ fixIds: [fixId48]
161790
162789
  });
161791
162790
 
161792
162791
  // src/services/codefixes/removeUnnecessaryAwait.ts
161793
- var fixId48 = "removeUnnecessaryAwait";
161794
- var errorCodes61 = [
162792
+ var fixId49 = "removeUnnecessaryAwait";
162793
+ var errorCodes62 = [
161795
162794
  Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
161796
162795
  ];
161797
162796
  registerCodeFix({
161798
- errorCodes: errorCodes61,
162797
+ errorCodes: errorCodes62,
161799
162798
  getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
161800
162799
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span));
161801
162800
  if (changes.length > 0) {
161802
- return [createCodeFixAction(fixId48, changes, Diagnostics.Remove_unnecessary_await, fixId48, Diagnostics.Remove_all_unnecessary_uses_of_await)];
162801
+ return [createCodeFixAction(fixId49, changes, Diagnostics.Remove_unnecessary_await, fixId49, Diagnostics.Remove_all_unnecessary_uses_of_await)];
161803
162802
  }
161804
162803
  },
161805
- fixIds: [fixId48],
162804
+ fixIds: [fixId49],
161806
162805
  getAllCodeActions: (context) => {
161807
- return codeFixAll(context, errorCodes61, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
162806
+ return codeFixAll(context, errorCodes62, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
161808
162807
  }
161809
162808
  });
161810
162809
  function makeChange11(changeTracker, sourceFile, span) {
@@ -161832,20 +162831,20 @@ function makeChange11(changeTracker, sourceFile, span) {
161832
162831
  }
161833
162832
 
161834
162833
  // src/services/codefixes/splitTypeOnlyImport.ts
161835
- var errorCodes62 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
161836
- var fixId49 = "splitTypeOnlyImport";
162834
+ var errorCodes63 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
162835
+ var fixId50 = "splitTypeOnlyImport";
161837
162836
  registerCodeFix({
161838
- errorCodes: errorCodes62,
161839
- fixIds: [fixId49],
162837
+ errorCodes: errorCodes63,
162838
+ fixIds: [fixId50],
161840
162839
  getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
161841
162840
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
161842
162841
  return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
161843
162842
  });
161844
162843
  if (changes.length) {
161845
- return [createCodeFixAction(fixId49, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId49, Diagnostics.Split_all_invalid_type_only_imports)];
162844
+ return [createCodeFixAction(fixId50, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId50, Diagnostics.Split_all_invalid_type_only_imports)];
161846
162845
  }
161847
162846
  },
161848
- getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, error2) => {
162847
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes63, (changes, error2) => {
161849
162848
  splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
161850
162849
  })
161851
162850
  });
@@ -161894,23 +162893,23 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
161894
162893
  }
161895
162894
 
161896
162895
  // src/services/codefixes/convertConstToLet.ts
161897
- var fixId50 = "fixConvertConstToLet";
161898
- var errorCodes63 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
162896
+ var fixId51 = "fixConvertConstToLet";
162897
+ var errorCodes64 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
161899
162898
  registerCodeFix({
161900
- errorCodes: errorCodes63,
162899
+ errorCodes: errorCodes64,
161901
162900
  getCodeActions: function getCodeActionsToConvertConstToLet(context) {
161902
162901
  const { sourceFile, span, program } = context;
161903
162902
  const info = getInfo21(sourceFile, span.start, program);
161904
162903
  if (info === void 0)
161905
162904
  return;
161906
162905
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
161907
- return [createCodeFixActionMaybeFixAll(fixId50, changes, Diagnostics.Convert_const_to_let, fixId50, Diagnostics.Convert_all_const_to_let)];
162906
+ return [createCodeFixActionMaybeFixAll(fixId51, changes, Diagnostics.Convert_const_to_let, fixId51, Diagnostics.Convert_all_const_to_let)];
161908
162907
  },
161909
162908
  getAllCodeActions: (context) => {
161910
162909
  const { program } = context;
161911
162910
  const seen = /* @__PURE__ */ new Map();
161912
162911
  return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
161913
- eachDiagnostic(context, errorCodes63, (diag2) => {
162912
+ eachDiagnostic(context, errorCodes64, (diag2) => {
161914
162913
  const info = getInfo21(diag2.file, diag2.start, program);
161915
162914
  if (info) {
161916
162915
  if (addToSeen(seen, getSymbolId(info.symbol))) {
@@ -161921,7 +162920,7 @@ registerCodeFix({
161921
162920
  });
161922
162921
  }));
161923
162922
  },
161924
- fixIds: [fixId50]
162923
+ fixIds: [fixId51]
161925
162924
  });
161926
162925
  function getInfo21(sourceFile, pos, program) {
161927
162926
  var _a;
@@ -161942,11 +162941,11 @@ function doChange40(changes, sourceFile, token) {
161942
162941
  }
161943
162942
 
161944
162943
  // src/services/codefixes/fixExpectedComma.ts
161945
- var fixId51 = "fixExpectedComma";
162944
+ var fixId52 = "fixExpectedComma";
161946
162945
  var expectedErrorCode = Diagnostics._0_expected.code;
161947
- var errorCodes64 = [expectedErrorCode];
162946
+ var errorCodes65 = [expectedErrorCode];
161948
162947
  registerCodeFix({
161949
- errorCodes: errorCodes64,
162948
+ errorCodes: errorCodes65,
161950
162949
  getCodeActions(context) {
161951
162950
  const { sourceFile } = context;
161952
162951
  const info = getInfo22(sourceFile, context.span.start, context.errorCode);
@@ -161954,15 +162953,15 @@ registerCodeFix({
161954
162953
  return void 0;
161955
162954
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
161956
162955
  return [createCodeFixAction(
161957
- fixId51,
162956
+ fixId52,
161958
162957
  changes,
161959
162958
  [Diagnostics.Change_0_to_1, ";", ","],
161960
- fixId51,
162959
+ fixId52,
161961
162960
  [Diagnostics.Change_0_to_1, ";", ","]
161962
162961
  )];
161963
162962
  },
161964
- fixIds: [fixId51],
161965
- getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, diag2) => {
162963
+ fixIds: [fixId52],
162964
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes65, (changes, diag2) => {
161966
162965
  const info = getInfo22(diag2.file, diag2.start, diag2.code);
161967
162966
  if (info)
161968
162967
  doChange41(changes, context.sourceFile, info);
@@ -161979,22 +162978,22 @@ function doChange41(changes, sourceFile, { node }) {
161979
162978
 
161980
162979
  // src/services/codefixes/fixAddVoidToPromise.ts
161981
162980
  var fixName7 = "addVoidToPromise";
161982
- var fixId52 = "addVoidToPromise";
161983
- var errorCodes65 = [
162981
+ var fixId53 = "addVoidToPromise";
162982
+ var errorCodes66 = [
161984
162983
  Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
161985
162984
  Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
161986
162985
  ];
161987
162986
  registerCodeFix({
161988
- errorCodes: errorCodes65,
161989
- fixIds: [fixId52],
162987
+ errorCodes: errorCodes66,
162988
+ fixIds: [fixId53],
161990
162989
  getCodeActions(context) {
161991
162990
  const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange12(t, context.sourceFile, context.span, context.program));
161992
162991
  if (changes.length > 0) {
161993
- return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId52, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
162992
+ return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId53, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
161994
162993
  }
161995
162994
  },
161996
162995
  getAllCodeActions(context) {
161997
- return codeFixAll(context, errorCodes65, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
162996
+ return codeFixAll(context, errorCodes66, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
161998
162997
  }
161999
162998
  });
162000
162999
  function makeChange12(changes, sourceFile, span, program, seen) {
@@ -178464,6 +179463,7 @@ __export(ts_exports2, {
178464
179463
  getBuildOrderFromAnyBuildOrder: () => getBuildOrderFromAnyBuildOrder,
178465
179464
  getBuilderCreationParameters: () => getBuilderCreationParameters,
178466
179465
  getBuilderFileEmit: () => getBuilderFileEmit,
179466
+ getCanonicalDiagnostic: () => getCanonicalDiagnostic,
178467
179467
  getCheckFlags: () => getCheckFlags,
178468
179468
  getClassExtendsHeritageElement: () => getClassExtendsHeritageElement,
178469
179469
  getClassLikeDeclarationOfSymbol: () => getClassLikeDeclarationOfSymbol,
@@ -180951,7 +181951,7 @@ __export(ts_server_protocol_exports, {
180951
181951
  NewLineKind: () => NewLineKind2,
180952
181952
  OrganizeImportsMode: () => OrganizeImportsMode,
180953
181953
  PollingWatchKind: () => PollingWatchKind2,
180954
- ScriptTarget: () => ScriptTarget10,
181954
+ ScriptTarget: () => ScriptTarget11,
180955
181955
  SemicolonPreference: () => SemicolonPreference,
180956
181956
  WatchDirectoryKind: () => WatchDirectoryKind2,
180957
181957
  WatchFileKind: () => WatchFileKind2
@@ -181140,24 +182140,24 @@ var NewLineKind2 = /* @__PURE__ */ ((NewLineKind3) => {
181140
182140
  NewLineKind3["Lf"] = "Lf";
181141
182141
  return NewLineKind3;
181142
182142
  })(NewLineKind2 || {});
181143
- var ScriptTarget10 = /* @__PURE__ */ ((ScriptTarget11) => {
181144
- ScriptTarget11["ES3"] = "es3";
181145
- ScriptTarget11["ES5"] = "es5";
181146
- ScriptTarget11["ES6"] = "es6";
181147
- ScriptTarget11["ES2015"] = "es2015";
181148
- ScriptTarget11["ES2016"] = "es2016";
181149
- ScriptTarget11["ES2017"] = "es2017";
181150
- ScriptTarget11["ES2018"] = "es2018";
181151
- ScriptTarget11["ES2019"] = "es2019";
181152
- ScriptTarget11["ES2020"] = "es2020";
181153
- ScriptTarget11["ES2021"] = "es2021";
181154
- ScriptTarget11["ES2022"] = "es2022";
181155
- ScriptTarget11["ES2023"] = "es2023";
181156
- ScriptTarget11["ESNext"] = "esnext";
181157
- ScriptTarget11["JSON"] = "json";
181158
- ScriptTarget11["Latest"] = "esnext" /* ESNext */;
181159
- return ScriptTarget11;
181160
- })(ScriptTarget10 || {});
182143
+ var ScriptTarget11 = /* @__PURE__ */ ((ScriptTarget12) => {
182144
+ ScriptTarget12["ES3"] = "es3";
182145
+ ScriptTarget12["ES5"] = "es5";
182146
+ ScriptTarget12["ES6"] = "es6";
182147
+ ScriptTarget12["ES2015"] = "es2015";
182148
+ ScriptTarget12["ES2016"] = "es2016";
182149
+ ScriptTarget12["ES2017"] = "es2017";
182150
+ ScriptTarget12["ES2018"] = "es2018";
182151
+ ScriptTarget12["ES2019"] = "es2019";
182152
+ ScriptTarget12["ES2020"] = "es2020";
182153
+ ScriptTarget12["ES2021"] = "es2021";
182154
+ ScriptTarget12["ES2022"] = "es2022";
182155
+ ScriptTarget12["ES2023"] = "es2023";
182156
+ ScriptTarget12["ESNext"] = "esnext";
182157
+ ScriptTarget12["JSON"] = "json";
182158
+ ScriptTarget12["Latest"] = "esnext" /* ESNext */;
182159
+ return ScriptTarget12;
182160
+ })(ScriptTarget11 || {});
181161
182161
  {
181162
182162
  }
181163
182163
 
@@ -190767,10 +191767,10 @@ ${e.message}`;
190767
191767
  }
190768
191768
  return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
190769
191769
  }
190770
- getCombinedCodeFix({ scope, fixId: fixId53 }, simplifiedResult) {
191770
+ getCombinedCodeFix({ scope, fixId: fixId54 }, simplifiedResult) {
190771
191771
  Debug.assert(scope.type === "file");
190772
191772
  const { file, project } = this.getFileAndProject(scope.args);
190773
- const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId53, this.getFormatOptions(file), this.getPreferences(file));
191773
+ const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId54, this.getFormatOptions(file), this.getPreferences(file));
190774
191774
  if (simplifiedResult) {
190775
191775
  return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
190776
191776
  } else {
@@ -190809,8 +191809,8 @@ ${e.message}`;
190809
191809
  mapCodeAction({ description: description3, changes, commands }) {
190810
191810
  return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
190811
191811
  }
190812
- mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId53, fixAllDescription }) {
190813
- return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId53, fixAllDescription };
191812
+ mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId54, fixAllDescription }) {
191813
+ return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId54, fixAllDescription };
190814
191814
  }
190815
191815
  mapTextChangesToCodeEdits(textChanges2) {
190816
191816
  return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
@@ -192891,6 +193891,7 @@ if (typeof console !== "undefined") {
192891
193891
  getBuildOrderFromAnyBuildOrder,
192892
193892
  getBuilderCreationParameters,
192893
193893
  getBuilderFileEmit,
193894
+ getCanonicalDiagnostic,
192894
193895
  getCheckFlags,
192895
193896
  getClassExtendsHeritageElement,
192896
193897
  getClassLikeDeclarationOfSymbol,