typescript 5.5.0-dev.20240424 → 5.5.0-dev.20240426

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.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240424`;
21
+ var version = `${versionMajorMinor}.0-dev.20240426`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6206,8 +6206,8 @@ var Diagnostics = {
6206
6206
  Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1530, 1 /* Error */, "Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v__1530", "Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
6207
6207
  _0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces: diag(1531, 1 /* Error */, "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1531", "'\\{0}' must be followed by a Unicode property value expression enclosed in braces."),
6208
6208
  There_is_no_capturing_group_named_0_in_this_regular_expression: diag(1532, 1 /* Error */, "There_is_no_capturing_group_named_0_in_this_regular_expression_1532", "There is no capturing group named '{0}' in this regular expression."),
6209
- A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1533, 1 /* Error */, "A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_1533", "A decimal escape must refer to an existent capturing group. There are only {0} capturing groups in this regular expression."),
6210
- Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression: diag(1534, 1 /* Error */, "Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression_1534", "Decimal escapes are invalid when there are no capturing groups in a regular expression."),
6209
+ This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1533, 1 /* Error */, "This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_r_1533", "This backreference refers to a group that does not exist. There are only {0} capturing groups in this regular expression."),
6210
+ This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups: diag(1534, 1 /* Error */, "This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups_1534", "This backreference is invalid because the containing regular expression contains no capturing groups."),
6211
6211
  This_character_cannot_be_escaped_in_a_regular_expression: diag(1535, 1 /* Error */, "This_character_cannot_be_escaped_in_a_regular_expression_1535", "This character cannot be escaped in a regular expression."),
6212
6212
  The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
6213
6213
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
@@ -8109,14 +8109,11 @@ var charToRegExpFlag = new Map(Object.entries({
8109
8109
  y: 128 /* Sticky */
8110
8110
  }));
8111
8111
  var regExpFlagToFirstAvailableLanguageVersion = /* @__PURE__ */ new Map([
8112
- [1 /* HasIndices */, 9 /* ES2022 */],
8113
- [2 /* Global */, 0 /* ES3 */],
8114
- [4 /* IgnoreCase */, 0 /* ES3 */],
8115
- [8 /* Multiline */, 0 /* ES3 */],
8116
- [16 /* DotAll */, 5 /* ES2018 */],
8117
- [32 /* Unicode */, 2 /* ES2015 */],
8118
- [64 /* UnicodeSets */, 99 /* ESNext */],
8119
- [128 /* Sticky */, 2 /* ES2015 */]
8112
+ [1 /* HasIndices */, 9 /* RegularExpressionFlagsHasIndices */],
8113
+ [16 /* DotAll */, 5 /* RegularExpressionFlagsDotAll */],
8114
+ [32 /* Unicode */, 2 /* RegularExpressionFlagsUnicode */],
8115
+ [64 /* UnicodeSets */, 99 /* RegularExpressionFlagsUnicodeSets */],
8116
+ [128 /* Sticky */, 2 /* RegularExpressionFlagsSticky */]
8120
8117
  ]);
8121
8118
  var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6e3, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43e3, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
8122
8119
  var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6e3, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43e3, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
@@ -9012,7 +9009,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9012
9009
  tokenFlags |= 2048 /* ContainsInvalidEscape */;
9013
9010
  if (isRegularExpression || shouldEmitInvalidEscapeError) {
9014
9011
  const code = parseInt(text.substring(start2 + 1, pos), 8);
9015
- error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
9012
+ if (isRegularExpression !== "annex-b") {
9013
+ error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
9014
+ }
9016
9015
  return String.fromCharCode(code);
9017
9016
  }
9018
9017
  return text.substring(start2, pos);
@@ -9043,7 +9042,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9043
9042
  case 117 /* u */:
9044
9043
  if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
9045
9044
  pos -= 2;
9046
- return scanExtendedUnicodeEscape(isRegularExpression || shouldEmitInvalidEscapeError);
9045
+ return scanExtendedUnicodeEscape(!!isRegularExpression || shouldEmitInvalidEscapeError);
9047
9046
  }
9048
9047
  for (; pos < start2 + 6; pos++) {
9049
9048
  if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
@@ -9093,7 +9092,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9093
9092
  case 8233 /* paragraphSeparator */:
9094
9093
  return "";
9095
9094
  default:
9096
- if (isRegularExpression && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
9095
+ if (isRegularExpression === true && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
9097
9096
  error(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2);
9098
9097
  }
9099
9098
  return String.fromCharCode(ch);
@@ -9788,7 +9787,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9788
9787
  pos = tokenStart + 1;
9789
9788
  return token = 64 /* EqualsToken */;
9790
9789
  }
9791
- function reScanSlashToken() {
9790
+ function reScanSlashToken(reportErrors2) {
9792
9791
  if (token === 44 /* SlashToken */ || token === 69 /* SlashEqualsToken */) {
9793
9792
  let p = tokenStart + 1;
9794
9793
  let inEscape = false;
@@ -9827,38 +9826,51 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9827
9826
  if (!isIdentifierPart(ch, languageVersion)) {
9828
9827
  break;
9829
9828
  }
9830
- const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
9831
- if (flag === void 0) {
9832
- error(Diagnostics.Unknown_regular_expression_flag, p, 1);
9833
- } else if (regExpFlags & flag) {
9834
- error(Diagnostics.Duplicate_regular_expression_flag, p, 1);
9835
- } else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
9836
- error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
9837
- } else {
9838
- regExpFlags |= flag;
9839
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
9840
- if (languageVersion < availableFrom) {
9841
- error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, getNameOfScriptTarget(availableFrom));
9829
+ if (reportErrors2) {
9830
+ const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
9831
+ if (flag === void 0) {
9832
+ error(Diagnostics.Unknown_regular_expression_flag, p, 1);
9833
+ } else if (regExpFlags & flag) {
9834
+ error(Diagnostics.Duplicate_regular_expression_flag, p, 1);
9835
+ } else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
9836
+ error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
9837
+ } else {
9838
+ regExpFlags |= flag;
9839
+ checkRegularExpressionFlagAvailable(flag, p);
9842
9840
  }
9843
9841
  }
9844
9842
  p++;
9845
9843
  }
9846
- pos = tokenStart + 1;
9847
- const saveTokenPos = tokenStart;
9848
- const saveTokenFlags = tokenFlags;
9849
- scanRegularExpressionWorker(text, endOfBody, regExpFlags, isUnterminated);
9850
- if (!isUnterminated) {
9844
+ if (reportErrors2) {
9845
+ pos = tokenStart + 1;
9846
+ const saveTokenPos = tokenStart;
9847
+ const saveTokenFlags = tokenFlags;
9848
+ scanRegularExpressionWorker(
9849
+ text,
9850
+ endOfBody,
9851
+ regExpFlags,
9852
+ isUnterminated,
9853
+ /*annexB*/
9854
+ true
9855
+ );
9856
+ if (!isUnterminated) {
9857
+ pos = p;
9858
+ }
9859
+ tokenStart = saveTokenPos;
9860
+ tokenFlags = saveTokenFlags;
9861
+ } else {
9851
9862
  pos = p;
9852
9863
  }
9853
- tokenStart = saveTokenPos;
9854
- tokenFlags = saveTokenFlags;
9855
9864
  tokenValue = text.substring(tokenStart, pos);
9856
9865
  token = 14 /* RegularExpressionLiteral */;
9857
9866
  }
9858
9867
  return token;
9859
- function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated) {
9860
- const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
9868
+ function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated, annexB) {
9861
9869
  const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
9870
+ const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
9871
+ if (unicodeMode) {
9872
+ annexB = false;
9873
+ }
9862
9874
  let mayContainStrings = false;
9863
9875
  let numberOfCapturingGroups = 0;
9864
9876
  const groupSpecifiers = /* @__PURE__ */ new Set();
@@ -9909,7 +9921,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9909
9921
  case 61 /* equals */:
9910
9922
  case 33 /* exclamation */:
9911
9923
  pos++;
9912
- isPreviousTermQuantifiable = false;
9924
+ isPreviousTermQuantifiable = annexB;
9913
9925
  break;
9914
9926
  case 60 /* lessThan */:
9915
9927
  const groupNameStart = pos;
@@ -10056,10 +10068,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10056
10068
  error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
10057
10069
  } else {
10058
10070
  currFlags |= flag;
10059
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
10060
- if (languageVersion < availableFrom) {
10061
- error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, getNameOfScriptTarget(availableFrom));
10062
- }
10071
+ checkRegularExpressionFlagAvailable(flag, pos);
10063
10072
  }
10064
10073
  pos++;
10065
10074
  }
@@ -10088,7 +10097,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10088
10097
  break;
10089
10098
  }
10090
10099
  default:
10091
- Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape());
10100
+ Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape(
10101
+ /*atomEscape*/
10102
+ true
10103
+ ));
10092
10104
  break;
10093
10105
  }
10094
10106
  }
@@ -10103,7 +10115,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10103
10115
  }
10104
10116
  return false;
10105
10117
  }
10106
- function scanCharacterEscape() {
10118
+ function scanCharacterEscape(atomEscape) {
10107
10119
  Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
10108
10120
  let ch = text2.charCodeAt(pos);
10109
10121
  switch (ch) {
@@ -10116,6 +10128,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10116
10128
  }
10117
10129
  if (unicodeMode) {
10118
10130
  error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
10131
+ } else if (atomEscape && annexB) {
10132
+ pos--;
10133
+ return "\\";
10119
10134
  }
10120
10135
  return String.fromCharCode(ch);
10121
10136
  case 94 /* caret */:
@@ -10145,7 +10160,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10145
10160
  /*shouldEmitInvalidEscapeError*/
10146
10161
  unicodeMode,
10147
10162
  /*isRegularExpression*/
10148
- true
10163
+ annexB ? "annex-b" : true
10149
10164
  );
10150
10165
  }
10151
10166
  }
@@ -10185,12 +10200,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10185
10200
  if (isClassContentExit(ch2)) {
10186
10201
  return;
10187
10202
  }
10188
- if (!minCharacter) {
10203
+ if (!minCharacter && !annexB) {
10189
10204
  error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
10190
10205
  }
10191
10206
  const maxStart = pos;
10192
10207
  const maxCharacter = scanClassAtom();
10193
- if (!maxCharacter) {
10208
+ if (!maxCharacter && !annexB) {
10194
10209
  error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
10195
10210
  continue;
10196
10211
  }
@@ -10473,7 +10488,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10473
10488
  pos++;
10474
10489
  return String.fromCharCode(ch2);
10475
10490
  default:
10476
- return scanCharacterEscape();
10491
+ return scanCharacterEscape(
10492
+ /*atomEscape*/
10493
+ false
10494
+ );
10477
10495
  }
10478
10496
  } else if (ch === text2.charCodeAt(pos + 1)) {
10479
10497
  switch (ch) {
@@ -10530,7 +10548,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10530
10548
  if (scanCharacterClassEscape()) {
10531
10549
  return "";
10532
10550
  }
10533
- return scanCharacterEscape();
10551
+ return scanCharacterEscape(
10552
+ /*atomEscape*/
10553
+ false
10554
+ );
10534
10555
  }
10535
10556
  } else {
10536
10557
  return scanSourceCharacter();
@@ -10645,15 +10666,21 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10645
10666
  }
10646
10667
  });
10647
10668
  forEach(decimalEscapes, (escape) => {
10648
- if (escape.value > numberOfCapturingGroups) {
10669
+ if (!annexB && escape.value > numberOfCapturingGroups) {
10649
10670
  if (numberOfCapturingGroups) {
10650
- error(Diagnostics.A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
10671
+ error(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
10651
10672
  } else {
10652
- error(Diagnostics.Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression, escape.pos, escape.end - escape.pos);
10673
+ error(Diagnostics.This_backreference_is_invalid_because_the_containing_regular_expression_contains_no_capturing_groups, escape.pos, escape.end - escape.pos);
10653
10674
  }
10654
10675
  }
10655
10676
  });
10656
10677
  }
10678
+ function checkRegularExpressionFlagAvailable(flag, pos2) {
10679
+ const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
10680
+ if (availableFrom && languageVersion < availableFrom) {
10681
+ error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
10682
+ }
10683
+ }
10657
10684
  }
10658
10685
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
10659
10686
  const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
@@ -45252,6 +45279,7 @@ function createTypeChecker(host) {
45252
45279
  var requestedExternalEmitHelperNames = /* @__PURE__ */ new Set();
45253
45280
  var requestedExternalEmitHelpers;
45254
45281
  var externalHelpersModule;
45282
+ var scanner;
45255
45283
  var Symbol12 = objectAllocator.getSymbolConstructor();
45256
45284
  var Type7 = objectAllocator.getTypeConstructor();
45257
45285
  var Signature5 = objectAllocator.getSignatureConstructor();
@@ -50111,7 +50139,8 @@ function createTypeChecker(host) {
50111
50139
  deepCloneOrReuseNode,
50112
50140
  /*context*/
50113
50141
  void 0,
50114
- deepCloneOrReuseNodes
50142
+ deepCloneOrReuseNodes,
50143
+ deepCloneOrReuseNode
50115
50144
  )), node);
50116
50145
  }
50117
50146
  function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
@@ -71090,6 +71119,53 @@ function createTypeChecker(host) {
71090
71119
  return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
71091
71120
  }
71092
71121
  }
71122
+ function checkGrammarRegularExpressionLiteral(node) {
71123
+ const sourceFile = getSourceFileOfNode(node);
71124
+ if (!hasParseDiagnostics(sourceFile)) {
71125
+ let lastError;
71126
+ scanner ?? (scanner = createScanner(
71127
+ 99 /* ESNext */,
71128
+ /*skipTrivia*/
71129
+ true
71130
+ ));
71131
+ scanner.setScriptTarget(sourceFile.languageVersion);
71132
+ scanner.setLanguageVariant(sourceFile.languageVariant);
71133
+ scanner.setOnError((message, length2, arg0) => {
71134
+ const start = scanner.getTokenEnd();
71135
+ if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
71136
+ const error2 = createDetachedDiagnostic(sourceFile.fileName, sourceFile.text, start, length2, message, arg0);
71137
+ addRelatedInfo(lastError, error2);
71138
+ } else if (!lastError || start !== lastError.start) {
71139
+ lastError = createFileDiagnostic(sourceFile, start, length2, message, arg0);
71140
+ diagnostics.add(lastError);
71141
+ }
71142
+ });
71143
+ scanner.setText(sourceFile.text, node.pos, node.end - node.pos);
71144
+ try {
71145
+ scanner.scan();
71146
+ Debug.assert(scanner.reScanSlashToken(
71147
+ /*reportErrors*/
71148
+ true
71149
+ ) === 14 /* RegularExpressionLiteral */, "Expected scanner to rescan RegularExpressionLiteral");
71150
+ return !!lastError;
71151
+ } finally {
71152
+ scanner.setText("");
71153
+ scanner.setOnError(
71154
+ /*onError*/
71155
+ void 0
71156
+ );
71157
+ }
71158
+ }
71159
+ return false;
71160
+ }
71161
+ function checkRegularExpressionLiteral(node) {
71162
+ const nodeLinks2 = getNodeLinks(node);
71163
+ if (!(nodeLinks2.flags & 1 /* TypeChecked */)) {
71164
+ nodeLinks2.flags |= 1 /* TypeChecked */;
71165
+ addLazyDiagnostic(() => checkGrammarRegularExpressionLiteral(node));
71166
+ }
71167
+ return globalRegExpType;
71168
+ }
71093
71169
  function checkSpreadExpression(node, checkMode) {
71094
71170
  if (languageVersion < 2 /* SpreadElements */) {
71095
71171
  checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
@@ -76993,7 +77069,7 @@ function createTypeChecker(host) {
76993
77069
  parent = parent.parent;
76994
77070
  }
76995
77071
  if (operator === 56 /* AmpersandAmpersandToken */ || isIfStatement(parent)) {
76996
- checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, isIfStatement(parent) ? parent.thenStatement : void 0);
77072
+ checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.left, leftType, isIfStatement(parent) ? parent.thenStatement : void 0);
76997
77073
  }
76998
77074
  checkTruthinessOfType(leftType, node.left);
76999
77075
  }
@@ -77551,7 +77627,7 @@ function createTypeChecker(host) {
77551
77627
  }
77552
77628
  function checkConditionalExpression(node, checkMode) {
77553
77629
  const type = checkTruthinessExpression(node.condition, checkMode);
77554
- checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
77630
+ checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.condition, type, node.whenTrue);
77555
77631
  const type1 = checkExpression(node.whenTrue, checkMode);
77556
77632
  const type2 = checkExpression(node.whenFalse, checkMode);
77557
77633
  return getUnionType([type1, type2], 2 /* Subtype */);
@@ -78024,7 +78100,7 @@ function createTypeChecker(host) {
78024
78100
  case 228 /* TemplateExpression */:
78025
78101
  return checkTemplateExpression(node);
78026
78102
  case 14 /* RegularExpressionLiteral */:
78027
- return globalRegExpType;
78103
+ return checkRegularExpressionLiteral(node);
78028
78104
  case 209 /* ArrayLiteralExpression */:
78029
78105
  return checkArrayLiteral(node, checkMode, forceTuple);
78030
78106
  case 210 /* ObjectLiteralExpression */:
@@ -80599,14 +80675,14 @@ function createTypeChecker(host) {
80599
80675
  function checkIfStatement(node) {
80600
80676
  checkGrammarStatementInAmbientContext(node);
80601
80677
  const type = checkTruthinessExpression(node.expression);
80602
- checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement);
80678
+ checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.expression, type, node.thenStatement);
80603
80679
  checkSourceElement(node.thenStatement);
80604
80680
  if (node.thenStatement.kind === 242 /* EmptyStatement */) {
80605
80681
  error(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
80606
80682
  }
80607
80683
  checkSourceElement(node.elseStatement);
80608
80684
  }
80609
- function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, condType, body) {
80685
+ function checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(condExpr, condType, body) {
80610
80686
  if (!strictNullChecks)
80611
80687
  return;
80612
80688
  bothHelper(condExpr, body);
@@ -80628,6 +80704,10 @@ function createTypeChecker(host) {
80628
80704
  return;
80629
80705
  }
80630
80706
  const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
80707
+ if (type.flags & 1024 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
80708
+ error(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
80709
+ return;
80710
+ }
80631
80711
  const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
80632
80712
  if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
80633
80713
  return;
@@ -83073,7 +83153,7 @@ function createTypeChecker(host) {
83073
83153
  if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
83074
83154
  return;
83075
83155
  }
83076
- if (!checkGrammarModifiers(node) && hasEffectiveModifiers(node)) {
83156
+ if (!checkGrammarModifiers(node) && node.modifiers) {
83077
83157
  grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
83078
83158
  }
83079
83159
  if (checkExternalImportOrExportDeclaration(node)) {
@@ -9456,6 +9456,7 @@ declare namespace ts {
9456
9456
  interface EmitOutput {
9457
9457
  outputFiles: OutputFile[];
9458
9458
  emitSkipped: boolean;
9459
+ diagnostics: readonly Diagnostic[];
9459
9460
  }
9460
9461
  interface OutputFile {
9461
9462
  name: string;