@typescript-deploys/pr-build 5.5.0-pr-55267-144 → 5.5.0-pr-58321-7

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 +23 -18
  2. package/lib/typescript.js +368 -558
  3. package/package.json +1 -1
package/lib/tsc.js CHANGED
@@ -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];
@@ -9839,10 +9836,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
9839
9836
  error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
9840
9837
  } else {
9841
9838
  regExpFlags |= flag;
9842
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
9843
- if (languageVersion < availableFrom) {
9844
- error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, getNameOfScriptTarget(availableFrom));
9845
- }
9839
+ checkRegularExpressionFlagAvailable(flag, p);
9846
9840
  }
9847
9841
  }
9848
9842
  p++;
@@ -10074,10 +10068,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10074
10068
  error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
10075
10069
  } else {
10076
10070
  currFlags |= flag;
10077
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
10078
- if (languageVersion < availableFrom) {
10079
- error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, getNameOfScriptTarget(availableFrom));
10080
- }
10071
+ checkRegularExpressionFlagAvailable(flag, pos);
10081
10072
  }
10082
10073
  pos++;
10083
10074
  }
@@ -10684,6 +10675,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
10684
10675
  }
10685
10676
  });
10686
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
+ }
10687
10684
  }
10688
10685
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
10689
10686
  const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
@@ -73181,11 +73178,19 @@ function createTypeChecker(host) {
73181
73178
  const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
73182
73179
  const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
73183
73180
  applyToParameterTypes(sourceSignature, signature, (source, target) => {
73184
- inferTypes(context.inferences, source, target);
73181
+ inferTypes(
73182
+ context.inferences,
73183
+ source,
73184
+ target,
73185
+ /*priority*/
73186
+ void 0,
73187
+ /*contravariant*/
73188
+ strictFunctionTypes
73189
+ );
73185
73190
  });
73186
73191
  if (!inferenceContext) {
73187
73192
  applyToReturnTypes(contextualSignature, signature, (source, target) => {
73188
- inferTypes(context.inferences, source, target, 128 /* ReturnType */);
73193
+ inferTypes(context.inferences, source, target);
73189
73194
  });
73190
73195
  }
73191
73196
  return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration));
package/lib/typescript.js CHANGED
@@ -1894,7 +1894,6 @@ __export(typescript_exports, {
1894
1894
  loadWithModeAwareCache: () => loadWithModeAwareCache,
1895
1895
  makeIdentifierFromModuleName: () => makeIdentifierFromModuleName,
1896
1896
  makeImport: () => makeImport,
1897
- makeImportIfNecessary: () => makeImportIfNecessary,
1898
1897
  makeStringLiteral: () => makeStringLiteral,
1899
1898
  mangleScopedPackageName: () => mangleScopedPackageName,
1900
1899
  map: () => map,
@@ -7285,12 +7284,15 @@ var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarge
7285
7284
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ArrowFunctions"] = 2 /* ES2015 */] = "ArrowFunctions";
7286
7285
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BlockScopedVariables"] = 2 /* ES2015 */] = "BlockScopedVariables";
7287
7286
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectAssign"] = 2 /* ES2015 */] = "ObjectAssign";
7287
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsUnicode"] = 2 /* ES2015 */] = "RegularExpressionFlagsUnicode";
7288
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsSticky"] = 2 /* ES2015 */] = "RegularExpressionFlagsSticky";
7288
7289
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Exponentiation"] = 3 /* ES2016 */] = "Exponentiation";
7289
7290
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncFunctions"] = 4 /* ES2017 */] = "AsyncFunctions";
7290
7291
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForAwaitOf"] = 5 /* ES2018 */] = "ForAwaitOf";
7291
7292
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncGenerators"] = 5 /* ES2018 */] = "AsyncGenerators";
7292
7293
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncIteration"] = 5 /* ES2018 */] = "AsyncIteration";
7293
7294
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectSpreadRest"] = 5 /* ES2018 */] = "ObjectSpreadRest";
7295
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsDotAll"] = 5 /* ES2018 */] = "RegularExpressionFlagsDotAll";
7294
7296
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindinglessCatch"] = 6 /* ES2019 */] = "BindinglessCatch";
7295
7297
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BigInt"] = 7 /* ES2020 */] = "BigInt";
7296
7298
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["NullishCoalesce"] = 7 /* ES2020 */] = "NullishCoalesce";
@@ -7299,9 +7301,11 @@ var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarge
7299
7301
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TopLevelAwait"] = 9 /* ES2022 */] = "TopLevelAwait";
7300
7302
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassFields"] = 9 /* ES2022 */] = "ClassFields";
7301
7303
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["PrivateNamesAndClassStaticBlocks"] = 9 /* ES2022 */] = "PrivateNamesAndClassStaticBlocks";
7304
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsHasIndices"] = 9 /* ES2022 */] = "RegularExpressionFlagsHasIndices";
7302
7305
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ShebangComments"] = 99 /* ESNext */] = "ShebangComments";
7303
7306
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["UsingAndAwaitUsing"] = 99 /* ESNext */] = "UsingAndAwaitUsing";
7304
7307
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassAndClassElementDecorators"] = 99 /* ESNext */] = "ClassAndClassElementDecorators";
7308
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsUnicodeSets"] = 99 /* ESNext */] = "RegularExpressionFlagsUnicodeSets";
7305
7309
  return LanguageFeatureMinimumTarget2;
7306
7310
  })(LanguageFeatureMinimumTarget || {});
7307
7311
  var ExternalEmitHelpers = /* @__PURE__ */ ((ExternalEmitHelpers2) => {
@@ -11716,14 +11720,11 @@ var charToRegExpFlag = new Map(Object.entries({
11716
11720
  y: 128 /* Sticky */
11717
11721
  }));
11718
11722
  var regExpFlagToFirstAvailableLanguageVersion = /* @__PURE__ */ new Map([
11719
- [1 /* HasIndices */, 9 /* ES2022 */],
11720
- [2 /* Global */, 0 /* ES3 */],
11721
- [4 /* IgnoreCase */, 0 /* ES3 */],
11722
- [8 /* Multiline */, 0 /* ES3 */],
11723
- [16 /* DotAll */, 5 /* ES2018 */],
11724
- [32 /* Unicode */, 2 /* ES2015 */],
11725
- [64 /* UnicodeSets */, 99 /* ESNext */],
11726
- [128 /* Sticky */, 2 /* ES2015 */]
11723
+ [1 /* HasIndices */, 9 /* RegularExpressionFlagsHasIndices */],
11724
+ [16 /* DotAll */, 5 /* RegularExpressionFlagsDotAll */],
11725
+ [32 /* Unicode */, 2 /* RegularExpressionFlagsUnicode */],
11726
+ [64 /* UnicodeSets */, 99 /* RegularExpressionFlagsUnicodeSets */],
11727
+ [128 /* Sticky */, 2 /* RegularExpressionFlagsSticky */]
11727
11728
  ]);
11728
11729
  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];
11729
11730
  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];
@@ -13470,10 +13471,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13470
13471
  error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
13471
13472
  } else {
13472
13473
  regExpFlags |= flag;
13473
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
13474
- if (languageVersion < availableFrom) {
13475
- error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, getNameOfScriptTarget(availableFrom));
13476
- }
13474
+ checkRegularExpressionFlagAvailable(flag, p);
13477
13475
  }
13478
13476
  }
13479
13477
  p++;
@@ -13705,10 +13703,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13705
13703
  error2(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
13706
13704
  } else {
13707
13705
  currFlags |= flag;
13708
- const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
13709
- if (languageVersion < availableFrom) {
13710
- error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, getNameOfScriptTarget(availableFrom));
13711
- }
13706
+ checkRegularExpressionFlagAvailable(flag, pos);
13712
13707
  }
13713
13708
  pos++;
13714
13709
  }
@@ -14315,6 +14310,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14315
14310
  }
14316
14311
  });
14317
14312
  }
14313
+ function checkRegularExpressionFlagAvailable(flag, pos2) {
14314
+ const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
14315
+ if (availableFrom && languageVersion < availableFrom) {
14316
+ error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
14317
+ }
14318
+ }
14318
14319
  }
14319
14320
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
14320
14321
  const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
@@ -78006,11 +78007,19 @@ function createTypeChecker(host) {
78006
78007
  const mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
78007
78008
  const sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
78008
78009
  applyToParameterTypes(sourceSignature, signature, (source, target) => {
78009
- inferTypes(context.inferences, source, target);
78010
+ inferTypes(
78011
+ context.inferences,
78012
+ source,
78013
+ target,
78014
+ /*priority*/
78015
+ void 0,
78016
+ /*contravariant*/
78017
+ strictFunctionTypes
78018
+ );
78010
78019
  });
78011
78020
  if (!inferenceContext) {
78012
78021
  applyToReturnTypes(contextualSignature, signature, (source, target) => {
78013
- inferTypes(context.inferences, source, target, 128 /* ReturnType */);
78022
+ inferTypes(context.inferences, source, target);
78014
78023
  });
78015
78024
  }
78016
78025
  return getSignatureInstantiation(signature, getInferredTypes(context), isInJSFile(contextualSignature.declaration));
@@ -137095,9 +137104,6 @@ function getModuleSpecifierResolverHost(program, host) {
137095
137104
  function moduleResolutionUsesNodeModules(moduleResolution) {
137096
137105
  return moduleResolution === 2 /* Node10 */ || moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
137097
137106
  }
137098
- function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
137099
- return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : void 0;
137100
- }
137101
137107
  function makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference, isTypeOnly) {
137102
137108
  return factory.createImportDeclaration(
137103
137109
  /*modifiers*/
@@ -137111,10 +137117,10 @@ function makeImport(defaultImport, namedImports, moduleSpecifier, quotePreferenc
137111
137117
  function makeStringLiteral(text, quotePreference) {
137112
137118
  return factory.createStringLiteral(text, quotePreference === 0 /* Single */);
137113
137119
  }
137114
- var QuotePreference = /* @__PURE__ */ ((QuotePreference7) => {
137115
- QuotePreference7[QuotePreference7["Single"] = 0] = "Single";
137116
- QuotePreference7[QuotePreference7["Double"] = 1] = "Double";
137117
- return QuotePreference7;
137120
+ var QuotePreference = /* @__PURE__ */ ((QuotePreference6) => {
137121
+ QuotePreference6[QuotePreference6["Single"] = 0] = "Single";
137122
+ QuotePreference6[QuotePreference6["Double"] = 1] = "Double";
137123
+ return QuotePreference6;
137118
137124
  })(QuotePreference || {});
137119
137125
  function quotePreferenceFromString(str, sourceFile) {
137120
137126
  return isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */;
@@ -142697,16 +142703,16 @@ function cleanText(text) {
142697
142703
  var ts_refactor_exports = {};
142698
142704
  __export(ts_refactor_exports, {
142699
142705
  addExportToChanges: () => addExportToChanges,
142700
- addExports: () => addExports,
142706
+ addImportsForMovedSymbols: () => addImportsForMovedSymbols,
142701
142707
  addNewFileToTsconfig: () => addNewFileToTsconfig,
142702
142708
  addOrRemoveBracesToArrowFunction: () => ts_refactor_addOrRemoveBracesToArrowFunction_exports,
142709
+ addTargetFileImports: () => addTargetFileImports,
142703
142710
  containsJsx: () => containsJsx,
142704
142711
  convertArrowFunctionOrFunctionExpression: () => ts_refactor_convertArrowFunctionOrFunctionExpression_exports,
142705
142712
  convertParamsToDestructuredObject: () => ts_refactor_convertParamsToDestructuredObject_exports,
142706
142713
  convertStringOrTemplateLiteral: () => ts_refactor_convertStringOrTemplateLiteral_exports,
142707
142714
  convertToOptionalChainExpression: () => ts_refactor_convertToOptionalChainExpression_exports,
142708
142715
  createNewFileName: () => createNewFileName,
142709
- createOldFileImportsFromTargetFile: () => createOldFileImportsFromTargetFile,
142710
142716
  deleteMovedStatements: () => deleteMovedStatements,
142711
142717
  deleteUnusedImports: () => deleteUnusedImports,
142712
142718
  deleteUnusedOldImports: () => deleteUnusedOldImports,
@@ -142717,13 +142723,13 @@ __export(ts_refactor_exports, {
142717
142723
  generateGetAccessorAndSetAccessor: () => ts_refactor_generateGetAccessorAndSetAccessor_exports,
142718
142724
  getApplicableRefactors: () => getApplicableRefactors,
142719
142725
  getEditsForRefactor: () => getEditsForRefactor,
142726
+ getNewStatementsAndRemoveFromOldFile: () => getNewStatementsAndRemoveFromOldFile,
142720
142727
  getStatementsToMove: () => getStatementsToMove,
142721
142728
  getTopLevelDeclarationStatement: () => getTopLevelDeclarationStatement,
142722
142729
  getUsageInfo: () => getUsageInfo,
142723
142730
  inferFunctionReturnType: () => ts_refactor_inferFunctionReturnType_exports,
142724
142731
  isRefactorErrorInfo: () => isRefactorErrorInfo,
142725
142732
  isTopLevelDeclaration: () => isTopLevelDeclaration,
142726
- makeImportOrRequire: () => makeImportOrRequire,
142727
142733
  moduleSpecifierFromImport: () => moduleSpecifierFromImport,
142728
142734
  nameOfTopLevelDeclaration: () => nameOfTopLevelDeclaration,
142729
142735
  refactorKindBeginsWith: () => refactorKindBeginsWith,
@@ -143595,282 +143601,12 @@ function getExpandedSelectionNode(firstType, enclosingNode) {
143595
143601
  }) ?? firstType;
143596
143602
  }
143597
143603
 
143598
- // src/services/refactors/helpers.ts
143599
- function isRefactorErrorInfo(info) {
143600
- return info.error !== void 0;
143601
- }
143602
- function refactorKindBeginsWith(known, requested) {
143603
- if (!requested)
143604
- return true;
143605
- return known.substr(0, requested.length) === requested;
143606
- }
143607
-
143608
- // src/services/refactors/inlineVariable.ts
143609
- var refactorName4 = "Inline variable";
143610
- var refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
143611
- var inlineVariableAction = {
143612
- name: refactorName4,
143613
- description: refactorDescription,
143614
- kind: "refactor.inline.variable"
143615
- };
143616
- registerRefactor(refactorName4, {
143617
- kinds: [inlineVariableAction.kind],
143618
- getAvailableActions(context) {
143619
- const {
143620
- file,
143621
- program,
143622
- preferences,
143623
- startPosition,
143624
- triggerReason
143625
- } = context;
143626
- const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
143627
- if (!info) {
143628
- return emptyArray;
143629
- }
143630
- if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
143631
- return [{
143632
- name: refactorName4,
143633
- description: refactorDescription,
143634
- actions: [inlineVariableAction]
143635
- }];
143636
- }
143637
- if (preferences.provideRefactorNotApplicableReason) {
143638
- return [{
143639
- name: refactorName4,
143640
- description: refactorDescription,
143641
- actions: [{
143642
- ...inlineVariableAction,
143643
- notApplicableReason: info.error
143644
- }]
143645
- }];
143646
- }
143647
- return emptyArray;
143648
- },
143649
- getEditsForAction(context, actionName2) {
143650
- Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
143651
- const { file, program, startPosition } = context;
143652
- const info = getInliningInfo(
143653
- file,
143654
- startPosition,
143655
- /*tryWithReferenceToken*/
143656
- true,
143657
- program
143658
- );
143659
- if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
143660
- return void 0;
143661
- }
143662
- const { references, declaration, replacement } = info;
143663
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
143664
- for (const node of references) {
143665
- tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
143666
- }
143667
- tracker.delete(file, declaration);
143668
- });
143669
- return { edits };
143670
- }
143671
- });
143672
- function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
143673
- var _a, _b;
143674
- const checker = program.getTypeChecker();
143675
- const token = getTouchingPropertyName(file, startPosition);
143676
- const parent2 = token.parent;
143677
- if (!isIdentifier(token)) {
143678
- return void 0;
143679
- }
143680
- if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
143681
- if (((_a = checker.getMergedSymbol(parent2.symbol).declarations) == null ? void 0 : _a.length) !== 1) {
143682
- return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
143683
- }
143684
- if (isDeclarationExported(parent2)) {
143685
- return void 0;
143686
- }
143687
- const references = getReferenceNodes(parent2, checker, file);
143688
- return references && { references, declaration: parent2, replacement: parent2.initializer };
143689
- }
143690
- if (tryWithReferenceToken) {
143691
- let definition = checker.resolveName(
143692
- token.text,
143693
- token,
143694
- 111551 /* Value */,
143695
- /*excludeGlobals*/
143696
- false
143697
- );
143698
- definition = definition && checker.getMergedSymbol(definition);
143699
- if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
143700
- return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
143701
- }
143702
- const declaration = definition.declarations[0];
143703
- if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
143704
- return void 0;
143705
- }
143706
- if (isDeclarationExported(declaration)) {
143707
- return void 0;
143708
- }
143709
- const references = getReferenceNodes(declaration, checker, file);
143710
- return references && { references, declaration, replacement: declaration.initializer };
143711
- }
143712
- return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
143713
- }
143714
- function isDeclarationExported(declaration) {
143715
- const variableStatement = cast(declaration.parent.parent, isVariableStatement);
143716
- return some(variableStatement.modifiers, isExportModifier);
143717
- }
143718
- function getReferenceNodes(declaration, checker, file) {
143719
- const references = [];
143720
- const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
143721
- if (ts_FindAllReferences_exports.isWriteAccessForReference(ref) && !isShorthandPropertyAssignment(ref.parent)) {
143722
- return true;
143723
- }
143724
- if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
143725
- return true;
143726
- }
143727
- if (isTypeQueryNode(ref.parent)) {
143728
- return true;
143729
- }
143730
- if (textRangeContainsPositionInclusive(declaration, ref.pos)) {
143731
- return true;
143732
- }
143733
- references.push(ref);
143734
- });
143735
- return references.length === 0 || cannotInline ? void 0 : references;
143736
- }
143737
- function getReplacementExpression(reference, replacement) {
143738
- replacement = getSynthesizedDeepClone(replacement);
143739
- const { parent: parent2 } = reference;
143740
- if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
143741
- return factory.createParenthesizedExpression(replacement);
143742
- }
143743
- if (isFunctionLike(replacement) && (isCallLikeExpression(parent2) || isPropertyAccessExpression(parent2))) {
143744
- return factory.createParenthesizedExpression(replacement);
143745
- }
143746
- if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
143747
- return factory.createParenthesizedExpression(replacement);
143748
- }
143749
- if (isIdentifier(reference) && isShorthandPropertyAssignment(parent2)) {
143750
- return factory.createPropertyAssignment(reference, replacement);
143751
- }
143752
- return replacement;
143753
- }
143754
-
143755
- // src/services/refactors/moveToNewFile.ts
143756
- var refactorName5 = "Move to a new file";
143757
- var description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
143758
- var moveToNewFileAction = {
143759
- name: refactorName5,
143760
- description,
143761
- kind: "refactor.move.newFile"
143762
- };
143763
- registerRefactor(refactorName5, {
143764
- kinds: [moveToNewFileAction.kind],
143765
- getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
143766
- const statements = getStatementsToMove(context);
143767
- if (context.preferences.allowTextChangesInNewFiles && statements) {
143768
- const file = context.file;
143769
- const affectedTextRange = {
143770
- start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
143771
- end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
143772
- };
143773
- return [{ name: refactorName5, description, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
143774
- }
143775
- if (context.preferences.provideRefactorNotApplicableReason) {
143776
- return [{ name: refactorName5, description, actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143777
- }
143778
- return emptyArray;
143779
- },
143780
- getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
143781
- Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
143782
- const statements = Debug.checkDefined(getStatementsToMove(context));
143783
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences));
143784
- return { edits, renameFilename: void 0, renameLocation: void 0 };
143785
- }
143786
- });
143787
- function doChange3(oldFile, program, toMove, changes, host, preferences) {
143788
- const checker = program.getTypeChecker();
143789
- const usage = getUsageInfo(oldFile, toMove.all, checker);
143790
- const newFilename = createNewFileName(oldFile, program, host, toMove);
143791
- changes.createNewFile(oldFile, newFilename, getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences));
143792
- addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
143793
- }
143794
- function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences) {
143795
- const checker = program.getTypeChecker();
143796
- const prologueDirectives = takeWhile(oldFile.statements, isPrologueDirective);
143797
- if (oldFile.externalModuleIndicator === void 0 && oldFile.commonJsModuleIndicator === void 0 && usage.oldImportsNeededByTargetFile.size === 0) {
143798
- deleteMovedStatements(oldFile, toMove.ranges, changes);
143799
- return [...prologueDirectives, ...toMove.all];
143800
- }
143801
- const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(newFilename, program, host, !!oldFile.commonJsModuleIndicator);
143802
- const quotePreference = getQuotePreference(oldFile, preferences);
143803
- const importsFromNewFile = createOldFileImportsFromTargetFile(oldFile, usage.oldFileImportsFromTargetFile, newFilename, program, host, useEsModuleSyntax, quotePreference);
143804
- if (importsFromNewFile) {
143805
- insertImports(
143806
- changes,
143807
- oldFile,
143808
- importsFromNewFile,
143809
- /*blankLineBetween*/
143810
- true,
143811
- preferences
143812
- );
143813
- }
143814
- deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
143815
- deleteMovedStatements(oldFile, toMove.ranges, changes);
143816
- updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, newFilename, quotePreference);
143817
- const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference);
143818
- const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromTargetFile, useEsModuleSyntax);
143819
- if (imports.length && body.length) {
143820
- return [
143821
- ...prologueDirectives,
143822
- ...imports,
143823
- 4 /* NewLineTrivia */,
143824
- ...body
143825
- ];
143826
- }
143827
- return [
143828
- ...prologueDirectives,
143829
- ...imports,
143830
- ...body
143831
- ];
143832
- }
143833
- function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference) {
143834
- const copiedOldImports = [];
143835
- for (const oldStatement of oldFile.statements) {
143836
- forEachImportInStatement(oldStatement, (i) => {
143837
- append(copiedOldImports, filterImport(i, moduleSpecifierFromImport(i), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
143838
- });
143839
- }
143840
- let oldFileDefault;
143841
- const oldFileNamedImports = [];
143842
- const markSeenTop = nodeSeenTracker();
143843
- newFileImportsFromOldFile.forEach((symbol) => {
143844
- if (!symbol.declarations) {
143845
- return;
143846
- }
143847
- for (const decl of symbol.declarations) {
143848
- if (!isTopLevelDeclaration(decl))
143849
- continue;
143850
- const name = nameOfTopLevelDeclaration(decl);
143851
- if (!name)
143852
- continue;
143853
- const top = getTopLevelDeclarationStatement(decl);
143854
- if (markSeenTop(top)) {
143855
- addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
143856
- }
143857
- if (hasSyntacticModifier(decl, 2048 /* Default */)) {
143858
- oldFileDefault = name;
143859
- } else {
143860
- oldFileNamedImports.push(name.text);
143861
- }
143862
- }
143863
- });
143864
- append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
143865
- return copiedOldImports;
143866
- }
143867
-
143868
143604
  // src/services/refactors/moveToFile.ts
143869
143605
  var refactorNameForMoveToFile = "Move to file";
143870
- var description2 = getLocaleSpecificMessage(Diagnostics.Move_to_file);
143606
+ var description = getLocaleSpecificMessage(Diagnostics.Move_to_file);
143871
143607
  var moveToFileAction = {
143872
143608
  name: "Move to file",
143873
- description: description2,
143609
+ description,
143874
143610
  kind: "refactor.move.file"
143875
143611
  };
143876
143612
  registerRefactor(refactorNameForMoveToFile, {
@@ -143893,10 +143629,10 @@ registerRefactor(refactorNameForMoveToFile, {
143893
143629
  start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
143894
143630
  end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
143895
143631
  };
143896
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
143632
+ return [{ name: refactorNameForMoveToFile, description, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
143897
143633
  }
143898
143634
  if (context.preferences.provideRefactorNotApplicableReason) {
143899
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143635
+ return [{ name: refactorNameForMoveToFile, description, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143900
143636
  }
143901
143637
  return emptyArray;
143902
143638
  },
@@ -143910,7 +143646,7 @@ registerRefactor(refactorNameForMoveToFile, {
143910
143646
  if (host.fileExists(targetFile) && program.getSourceFile(targetFile) === void 0) {
143911
143647
  return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_statements_to_the_selected_file));
143912
143648
  }
143913
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
143649
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
143914
143650
  return { edits, renameFilename: void 0, renameLocation: void 0 };
143915
143651
  }
143916
143652
  return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid));
@@ -143919,144 +143655,46 @@ registerRefactor(refactorNameForMoveToFile, {
143919
143655
  function error(notApplicableReason) {
143920
143656
  return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason };
143921
143657
  }
143922
- function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
143658
+ function doChange3(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
143923
143659
  const checker = program.getTypeChecker();
143924
- if (!host.fileExists(targetFile)) {
143925
- changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, getUsageInfo(oldFile, toMove.all, checker), changes, toMove, program, host, preferences));
143660
+ const isForNewFile = !host.fileExists(targetFile);
143661
+ const targetSourceFile = isForNewFile ? createFutureSourceFile(targetFile, oldFile.externalModuleIndicator ? 99 /* ESNext */ : oldFile.commonJsModuleIndicator ? 1 /* CommonJS */ : void 0, program, host) : Debug.checkDefined(program.getSourceFile(targetFile));
143662
+ const importAdderForOldFile = ts_codefix_exports.createImportAdder(oldFile, context.program, context.preferences, context.host);
143663
+ const importAdderForNewFile = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host);
143664
+ getNewStatementsAndRemoveFromOldFile(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, isForNewFile ? void 0 : getExistingLocals(targetSourceFile, toMove.all, checker)), changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile);
143665
+ if (isForNewFile) {
143926
143666
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
143927
- } else {
143928
- const targetSourceFile = Debug.checkDefined(program.getSourceFile(targetFile));
143929
- const importAdder = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host);
143930
- getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, getExistingLocals(targetSourceFile, toMove.all, checker)), changes, toMove, program, host, preferences, importAdder);
143931
143667
  }
143932
143668
  }
143933
- function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) {
143669
+ function getNewStatementsAndRemoveFromOldFile(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile) {
143934
143670
  const checker = program.getTypeChecker();
143935
143671
  const prologueDirectives = takeWhile(oldFile.statements, isPrologueDirective);
143936
- if (oldFile.externalModuleIndicator === void 0 && oldFile.commonJsModuleIndicator === void 0 && usage.oldImportsNeededByTargetFile.size === 0 && usage.targetFileImportsFromOldFile.size === 0 && typeof targetFile === "string") {
143937
- deleteMovedStatements(oldFile, toMove.ranges, changes);
143938
- return [...prologueDirectives, ...toMove.all];
143939
- }
143940
- const targetFileName = typeof targetFile === "string" ? targetFile : targetFile.fileName;
143941
- const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(targetFileName, program, host, !!oldFile.commonJsModuleIndicator);
143672
+ const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(targetFile.fileName, program, host, !!oldFile.commonJsModuleIndicator);
143942
143673
  const quotePreference = getQuotePreference(oldFile, preferences);
143943
- const importsFromTargetFile = createOldFileImportsFromTargetFile(oldFile, usage.oldFileImportsFromTargetFile, targetFileName, program, host, useEsModuleSyntax, quotePreference);
143944
- if (importsFromTargetFile) {
143945
- insertImports(
143946
- changes,
143947
- oldFile,
143948
- importsFromTargetFile,
143674
+ addImportsForMovedSymbols(usage.oldFileImportsFromTargetFile, targetFile.fileName, importAdderForOldFile, program);
143675
+ deleteUnusedOldImports(oldFile, toMove.all, usage.unusedImportsFromOldFile, importAdderForOldFile);
143676
+ importAdderForOldFile.writeFixes(changes, quotePreference);
143677
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
143678
+ updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, targetFile.fileName, quotePreference);
143679
+ addExportsInOldFile(oldFile, usage.targetFileImportsFromOldFile, changes, useEsModuleSyntax);
143680
+ addTargetFileImports(oldFile, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile, checker, program, importAdderForNewFile);
143681
+ if (!isFullSourceFile(targetFile) && prologueDirectives.length) {
143682
+ changes.insertStatementsInNewFile(targetFile.fileName, prologueDirectives, oldFile);
143683
+ }
143684
+ importAdderForNewFile.writeFixes(changes, quotePreference);
143685
+ const body = addExports(oldFile, toMove.all, arrayFrom(usage.oldFileImportsFromTargetFile.keys()), useEsModuleSyntax);
143686
+ if (isFullSourceFile(targetFile) && targetFile.statements.length > 0) {
143687
+ moveStatementsToTargetFile(changes, program, body, targetFile, toMove);
143688
+ } else if (isFullSourceFile(targetFile)) {
143689
+ changes.insertNodesAtEndOfFile(
143690
+ targetFile,
143691
+ body,
143949
143692
  /*blankLineBetween*/
143950
- true,
143951
- preferences
143693
+ false
143952
143694
  );
143953
- }
143954
- deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
143955
- deleteMovedStatements(oldFile, toMove.ranges, changes);
143956
- updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, targetFileName, quotePreference);
143957
- const imports = getTargetFileImportsAndAddExportInOldFile(oldFile, targetFileName, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference, importAdder);
143958
- const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromTargetFile, useEsModuleSyntax);
143959
- if (typeof targetFile !== "string") {
143960
- if (targetFile.statements.length > 0) {
143961
- moveStatementsToTargetFile(changes, program, body, targetFile, toMove);
143962
- } else {
143963
- changes.insertNodesAtEndOfFile(
143964
- targetFile,
143965
- body,
143966
- /*blankLineBetween*/
143967
- false
143968
- );
143969
- }
143970
- if (imports.length > 0) {
143971
- insertImports(
143972
- changes,
143973
- targetFile,
143974
- imports,
143975
- /*blankLineBetween*/
143976
- true,
143977
- preferences
143978
- );
143979
- }
143980
- }
143981
- if (importAdder) {
143982
- importAdder.writeFixes(changes, quotePreference);
143983
- }
143984
- if (imports.length && body.length) {
143985
- return [
143986
- ...prologueDirectives,
143987
- ...imports,
143988
- 4 /* NewLineTrivia */,
143989
- ...body
143990
- ];
143991
- }
143992
- return [
143993
- ...prologueDirectives,
143994
- ...imports,
143995
- ...body
143996
- ];
143997
- }
143998
- function getTargetFileImportsAndAddExportInOldFile(oldFile, targetFile, importsToCopy, targetFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference, importAdder) {
143999
- const copiedOldImports = [];
144000
- if (importAdder) {
144001
- importsToCopy.forEach((isValidTypeOnlyUseSite, symbol) => {
144002
- try {
144003
- importAdder.addImportFromExportedSymbol(skipAlias(symbol, checker), isValidTypeOnlyUseSite);
144004
- } catch {
144005
- for (const oldStatement of oldFile.statements) {
144006
- forEachImportInStatement(oldStatement, (i) => {
144007
- append(copiedOldImports, filterImport(i, factory.createStringLiteral(moduleSpecifierFromImport(i).text), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
144008
- });
144009
- }
144010
- }
144011
- });
144012
143695
  } else {
144013
- const targetSourceFile = program.getSourceFile(targetFile);
144014
- for (const oldStatement of oldFile.statements) {
144015
- forEachImportInStatement(oldStatement, (i) => {
144016
- var _a;
144017
- const moduleSpecifier = moduleSpecifierFromImport(i);
144018
- const compilerOptions = program.getCompilerOptions();
144019
- const resolved = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier);
144020
- const fileName = (_a = resolved == null ? void 0 : resolved.resolvedModule) == null ? void 0 : _a.resolvedFileName;
144021
- if (fileName && targetSourceFile) {
144022
- const newModuleSpecifier = getModuleSpecifier(compilerOptions, targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host));
144023
- append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
144024
- } else {
144025
- append(copiedOldImports, filterImport(i, factory.createStringLiteral(moduleSpecifierFromImport(i).text), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
144026
- }
144027
- });
144028
- }
143696
+ changes.insertStatementsInNewFile(targetFile.fileName, importAdderForNewFile.hasFixes() ? [4 /* NewLineTrivia */, ...body] : body, oldFile);
144029
143697
  }
144030
- const targetFileSourceFile = program.getSourceFile(targetFile);
144031
- let oldFileDefault;
144032
- const oldFileNamedImports = [];
144033
- const markSeenTop = nodeSeenTracker();
144034
- targetFileImportsFromOldFile.forEach((symbol) => {
144035
- if (!symbol.declarations) {
144036
- return;
144037
- }
144038
- for (const decl of symbol.declarations) {
144039
- if (!isTopLevelDeclaration(decl))
144040
- continue;
144041
- const name = nameOfTopLevelDeclaration(decl);
144042
- if (!name)
144043
- continue;
144044
- const top = getTopLevelDeclarationStatement(decl);
144045
- if (markSeenTop(top)) {
144046
- addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
144047
- }
144048
- if (importAdder && checker.isUnknownSymbol(symbol)) {
144049
- importAdder.addImportFromExportedSymbol(skipAlias(symbol, checker));
144050
- } else {
144051
- if (hasSyntacticModifier(decl, 2048 /* Default */)) {
144052
- oldFileDefault = name;
144053
- } else {
144054
- oldFileNamedImports.push(name.text);
144055
- }
144056
- }
144057
- }
144058
- });
144059
- return targetFileSourceFile ? append(copiedOldImports, makeImportOrRequire(targetFileSourceFile, oldFileDefault, oldFileNamedImports, oldFile.fileName, program, host, useEsModuleSyntax, quotePreference)) : append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, oldFile.fileName, program, host, useEsModuleSyntax, quotePreference));
144060
143698
  }
144061
143699
  function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
144062
143700
  const cfg = program.getCompilerOptions().configFile;
@@ -144075,13 +143713,38 @@ function deleteMovedStatements(sourceFile, moved, changes) {
144075
143713
  changes.deleteNodeRangeExcludingEnd(sourceFile, first2, afterLast);
144076
143714
  }
144077
143715
  }
144078
- function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
143716
+ function deleteUnusedOldImports(oldFile, toMove, toDelete, importAdder) {
144079
143717
  for (const statement of oldFile.statements) {
144080
143718
  if (contains(toMove, statement))
144081
143719
  continue;
144082
- forEachImportInStatement(statement, (i) => deleteUnusedImports(oldFile, i, changes, (name) => toDelete.has(checker.getSymbolAtLocation(name))));
143720
+ forEachImportInStatement(statement, (i) => {
143721
+ forEachAliasDeclarationInImportOrRequire(i, (decl) => {
143722
+ if (toDelete.has(decl.symbol)) {
143723
+ importAdder.removeExistingImport(decl);
143724
+ }
143725
+ });
143726
+ });
144083
143727
  }
144084
143728
  }
143729
+ function addExportsInOldFile(oldFile, targetFileImportsFromOldFile, changes, useEsModuleSyntax) {
143730
+ const markSeenTop = nodeSeenTracker();
143731
+ targetFileImportsFromOldFile.forEach((_, symbol) => {
143732
+ if (!symbol.declarations) {
143733
+ return;
143734
+ }
143735
+ for (const decl of symbol.declarations) {
143736
+ if (!isTopLevelDeclaration(decl))
143737
+ continue;
143738
+ const name = nameOfTopLevelDeclaration(decl);
143739
+ if (!name)
143740
+ continue;
143741
+ const top = getTopLevelDeclarationStatement(decl);
143742
+ if (markSeenTop(top)) {
143743
+ addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
143744
+ }
143745
+ }
143746
+ });
143747
+ }
144085
143748
  function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols, targetFileName, quotePreference) {
144086
143749
  const checker = program.getTypeChecker();
144087
143750
  for (const sourceFile of program.getSourceFiles()) {
@@ -144220,45 +143883,39 @@ function forEachImportInStatement(statement, cb) {
144220
143883
  }
144221
143884
  }
144222
143885
  }
144223
- function createOldFileImportsFromTargetFile(sourceFile, targetFileNeedExport, targetFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
144224
- let defaultImport;
144225
- const imports = [];
144226
- targetFileNeedExport.forEach((symbol) => {
144227
- if (symbol.escapedName === "default" /* Default */) {
144228
- defaultImport = factory.createIdentifier(symbolNameNoDefault(symbol));
144229
- } else {
144230
- imports.push(symbol.name);
143886
+ function forEachAliasDeclarationInImportOrRequire(importOrRequire, cb) {
143887
+ var _a, _b, _c, _d, _e;
143888
+ if (importOrRequire.kind === 272 /* ImportDeclaration */) {
143889
+ if ((_a = importOrRequire.importClause) == null ? void 0 : _a.name) {
143890
+ cb(importOrRequire.importClause);
144231
143891
  }
144232
- });
144233
- return makeImportOrRequire(sourceFile, defaultImport, imports, targetFileNameWithExtension, program, host, useEs6Imports, quotePreference);
143892
+ if (((_c = (_b = importOrRequire.importClause) == null ? void 0 : _b.namedBindings) == null ? void 0 : _c.kind) === 274 /* NamespaceImport */) {
143893
+ cb(importOrRequire.importClause.namedBindings);
143894
+ }
143895
+ if (((_e = (_d = importOrRequire.importClause) == null ? void 0 : _d.namedBindings) == null ? void 0 : _e.kind) === 275 /* NamedImports */) {
143896
+ for (const element of importOrRequire.importClause.namedBindings.elements) {
143897
+ cb(element);
143898
+ }
143899
+ }
143900
+ } else if (importOrRequire.kind === 271 /* ImportEqualsDeclaration */) {
143901
+ cb(importOrRequire);
143902
+ } else if (importOrRequire.kind === 260 /* VariableDeclaration */) {
143903
+ if (importOrRequire.name.kind === 80 /* Identifier */) {
143904
+ cb(importOrRequire);
143905
+ } else if (importOrRequire.name.kind === 206 /* ObjectBindingPattern */) {
143906
+ for (const element of importOrRequire.name.elements) {
143907
+ if (isIdentifier(element.name)) {
143908
+ cb(element);
143909
+ }
143910
+ }
143911
+ }
143912
+ }
144234
143913
  }
144235
- function makeImportOrRequire(sourceFile, defaultImport, imports, targetFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
144236
- const pathToTargetFile = resolvePath(getDirectoryPath(getNormalizedAbsolutePath(sourceFile.fileName, program.getCurrentDirectory())), targetFileNameWithExtension);
144237
- const pathToTargetFileWithCorrectExtension = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.fileName, pathToTargetFile, createModuleSpecifierResolutionHost(program, host));
144238
- if (useEs6Imports) {
144239
- const specifiers = imports.map((i) => factory.createImportSpecifier(
144240
- /*isTypeOnly*/
144241
- false,
144242
- /*propertyName*/
144243
- void 0,
144244
- factory.createIdentifier(i)
144245
- ));
144246
- return makeImportIfNecessary(defaultImport, specifiers, pathToTargetFileWithCorrectExtension, quotePreference);
144247
- } else {
144248
- Debug.assert(!defaultImport, "No default import should exist");
144249
- const bindingElements = imports.map((i) => factory.createBindingElement(
144250
- /*dotDotDotToken*/
144251
- void 0,
144252
- /*propertyName*/
144253
- void 0,
144254
- i
144255
- ));
144256
- return bindingElements.length ? makeVariableStatement(
144257
- factory.createObjectBindingPattern(bindingElements),
144258
- /*type*/
144259
- void 0,
144260
- createRequireCall(makeStringLiteral(pathToTargetFileWithCorrectExtension, quotePreference))
144261
- ) : void 0;
143914
+ function addImportsForMovedSymbols(symbols, targetFileName, importAdder, program) {
143915
+ for (const [symbol, isValidTypeOnlyUseSite] of symbols) {
143916
+ const symbolName2 = getNameForExportedSymbol(symbol, getEmitScriptTarget(program.getCompilerOptions()));
143917
+ const exportKind = symbol.name === "default" && symbol.parent ? 1 /* Default */ : 0 /* Named */;
143918
+ importAdder.addImportForNonExistentExport(symbolName2, targetFileName, exportKind, symbol.flags, isValidTypeOnlyUseSite);
144262
143919
  }
144263
143920
  }
144264
143921
  function makeVariableStatement(name, type, initializer, flags = 2 /* Const */) {
@@ -144278,7 +143935,7 @@ function addExports(sourceFile, toMove, needExport, useEs6Exports) {
144278
143935
  return flatMap(toMove, (statement) => {
144279
143936
  if (isTopLevelDeclarationStatement(statement) && !isExported(sourceFile, statement, useEs6Exports) && forEachTopLevelDeclaration(statement, (d) => {
144280
143937
  var _a;
144281
- return needExport.has(Debug.checkDefined((_a = tryCast(d, canHaveSymbol)) == null ? void 0 : _a.symbol));
143938
+ return needExport.includes(Debug.checkDefined((_a = tryCast(d, canHaveSymbol)) == null ? void 0 : _a.symbol));
144282
143939
  })) {
144283
143940
  const exports2 = addExport(getSynthesizedDeepClone(statement), useEs6Exports);
144284
143941
  if (exports2)
@@ -144295,86 +143952,17 @@ function isExported(sourceFile, decl, useEs6Exports, name) {
144295
143952
  return !!sourceFile.symbol && !!sourceFile.symbol.exports && getNamesToExportInCommonJS(decl).some((name2) => sourceFile.symbol.exports.has(escapeLeadingUnderscores(name2)));
144296
143953
  }
144297
143954
  function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) {
144298
- switch (importDecl.kind) {
144299
- case 272 /* ImportDeclaration */:
144300
- deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused);
144301
- break;
144302
- case 271 /* ImportEqualsDeclaration */:
144303
- if (isUnused(importDecl.name)) {
144304
- changes.delete(sourceFile, importDecl);
144305
- }
144306
- break;
144307
- case 260 /* VariableDeclaration */:
144308
- deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused);
144309
- break;
144310
- default:
144311
- Debug.assertNever(importDecl, `Unexpected import decl kind ${importDecl.kind}`);
144312
- }
144313
- }
144314
- function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) {
144315
- if (!importDecl.importClause)
144316
- return;
144317
- const { name, namedBindings } = importDecl.importClause;
144318
- const defaultUnused = !name || isUnused(name);
144319
- const namedBindingsUnused = !namedBindings || (namedBindings.kind === 274 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every((e) => isUnused(e.name)));
144320
- if (defaultUnused && namedBindingsUnused) {
144321
- changes.delete(sourceFile, importDecl);
144322
- } else {
144323
- if (name && defaultUnused) {
144324
- changes.delete(sourceFile, name);
143955
+ if (importDecl.kind === 272 /* ImportDeclaration */ && importDecl.importClause) {
143956
+ const { name, namedBindings } = importDecl.importClause;
143957
+ if ((!name || isUnused(name)) && (!namedBindings || namedBindings.kind === 275 /* NamedImports */ && namedBindings.elements.length !== 0 && namedBindings.elements.every((e) => isUnused(e.name)))) {
143958
+ return changes.delete(sourceFile, importDecl);
144325
143959
  }
144326
- if (namedBindings) {
144327
- if (namedBindingsUnused) {
144328
- changes.replaceNode(
144329
- sourceFile,
144330
- importDecl.importClause,
144331
- factory.updateImportClause(
144332
- importDecl.importClause,
144333
- importDecl.importClause.isTypeOnly,
144334
- name,
144335
- /*namedBindings*/
144336
- void 0
144337
- )
144338
- );
144339
- } else if (namedBindings.kind === 275 /* NamedImports */) {
144340
- for (const element of namedBindings.elements) {
144341
- if (isUnused(element.name))
144342
- changes.delete(sourceFile, element);
144343
- }
144344
- }
144345
- }
144346
- }
144347
- }
144348
- function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) {
144349
- const { name } = varDecl;
144350
- switch (name.kind) {
144351
- case 80 /* Identifier */:
144352
- if (isUnused(name)) {
144353
- if (varDecl.initializer && isRequireCall(
144354
- varDecl.initializer,
144355
- /*requireStringLiteralLikeArgument*/
144356
- true
144357
- )) {
144358
- changes.delete(sourceFile, isVariableDeclarationList(varDecl.parent) && length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
144359
- } else {
144360
- changes.delete(sourceFile, name);
144361
- }
144362
- }
144363
- break;
144364
- case 207 /* ArrayBindingPattern */:
144365
- break;
144366
- case 206 /* ObjectBindingPattern */:
144367
- if (name.elements.every((e) => isIdentifier(e.name) && isUnused(e.name))) {
144368
- changes.delete(sourceFile, isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl);
144369
- } else {
144370
- for (const element of name.elements) {
144371
- if (isIdentifier(element.name) && isUnused(element.name)) {
144372
- changes.delete(sourceFile, element.name);
144373
- }
144374
- }
144375
- }
144376
- break;
144377
143960
  }
143961
+ forEachAliasDeclarationInImportOrRequire(importDecl, (i) => {
143962
+ if (i.name && isIdentifier(i.name) && isUnused(i.name)) {
143963
+ changes.delete(sourceFile, i);
143964
+ }
143965
+ });
144378
143966
  }
144379
143967
  function isTopLevelDeclarationStatement(node) {
144380
143968
  Debug.assert(isSourceFile(node.parent), "Node parent should be a SourceFile");
@@ -144598,12 +144186,13 @@ function isPureImport(node) {
144598
144186
  }
144599
144187
  }
144600
144188
  function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PURE__ */ new Set()) {
144189
+ var _a;
144601
144190
  const movedSymbols = /* @__PURE__ */ new Set();
144602
144191
  const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map();
144603
- const targetFileImportsFromOldFile = /* @__PURE__ */ new Set();
144192
+ const targetFileImportsFromOldFile = /* @__PURE__ */ new Map();
144604
144193
  const jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx(toMove));
144605
144194
  if (jsxNamespaceSymbol) {
144606
- oldImportsNeededByTargetFile.set(jsxNamespaceSymbol, false);
144195
+ oldImportsNeededByTargetFile.set(jsxNamespaceSymbol, [false, tryCast((_a = jsxNamespaceSymbol.declarations) == null ? void 0 : _a[0], (d) => isImportSpecifier(d) || isImportClause(d) || isNamespaceImport(d) || isImportEqualsDeclaration(d) || isBindingElement(d) || isVariableDeclaration(d))]);
144607
144196
  }
144608
144197
  for (const statement of toMove) {
144609
144198
  forEachTopLevelDeclaration(statement, (decl) => {
@@ -144623,9 +144212,12 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
144623
144212
  for (const decl of symbol.declarations) {
144624
144213
  if (isInImport(decl)) {
144625
144214
  const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol);
144626
- oldImportsNeededByTargetFile.set(symbol, prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite);
144215
+ oldImportsNeededByTargetFile.set(symbol, [
144216
+ prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite,
144217
+ tryCast(decl, (d) => isImportSpecifier(d) || isImportClause(d) || isNamespaceImport(d) || isImportEqualsDeclaration(d) || isBindingElement(d) || isVariableDeclaration(d))
144218
+ ]);
144627
144219
  } else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) {
144628
- targetFileImportsFromOldFile.add(symbol);
144220
+ targetFileImportsFromOldFile.set(symbol, isValidTypeOnlyUseSite);
144629
144221
  }
144630
144222
  }
144631
144223
  });
@@ -144633,16 +144225,16 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
144633
144225
  for (const unusedImport of oldImportsNeededByTargetFile.keys()) {
144634
144226
  unusedImportsFromOldFile.add(unusedImport);
144635
144227
  }
144636
- const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set();
144228
+ const oldFileImportsFromTargetFile = /* @__PURE__ */ new Map();
144637
144229
  for (const statement of oldFile.statements) {
144638
144230
  if (contains(toMove, statement))
144639
144231
  continue;
144640
144232
  if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) {
144641
144233
  unusedImportsFromOldFile.delete(jsxNamespaceSymbol);
144642
144234
  }
144643
- forEachReference(statement, checker, (symbol) => {
144235
+ forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
144644
144236
  if (movedSymbols.has(symbol))
144645
- oldFileImportsFromTargetFile.add(symbol);
144237
+ oldFileImportsFromTargetFile.set(symbol, isValidTypeOnlyUseSite);
144646
144238
  unusedImportsFromOldFile.delete(symbol);
144647
144239
  });
144648
144240
  }
@@ -144850,6 +144442,218 @@ function getExistingLocals(sourceFile, statements, checker) {
144850
144442
  return existingLocals;
144851
144443
  }
144852
144444
 
144445
+ // src/services/refactors/helpers.ts
144446
+ function isRefactorErrorInfo(info) {
144447
+ return info.error !== void 0;
144448
+ }
144449
+ function refactorKindBeginsWith(known, requested) {
144450
+ if (!requested)
144451
+ return true;
144452
+ return known.substr(0, requested.length) === requested;
144453
+ }
144454
+ function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFile, checker, program, importAdder) {
144455
+ importsToCopy.forEach(([isValidTypeOnlyUseSite, declaration], symbol) => {
144456
+ var _a;
144457
+ const targetSymbol = skipAlias(symbol, checker);
144458
+ if (checker.isUnknownSymbol(targetSymbol)) {
144459
+ importAdder.addVerbatimImport(Debug.checkDefined(declaration ?? findAncestor((_a = symbol.declarations) == null ? void 0 : _a[0], isAnyImportOrRequireStatement)));
144460
+ } else {
144461
+ importAdder.addImportFromExportedSymbol(targetSymbol, isValidTypeOnlyUseSite, declaration);
144462
+ }
144463
+ });
144464
+ addImportsForMovedSymbols(targetFileImportsFromOldFile, oldFile.fileName, importAdder, program);
144465
+ }
144466
+
144467
+ // src/services/refactors/inlineVariable.ts
144468
+ var refactorName4 = "Inline variable";
144469
+ var refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
144470
+ var inlineVariableAction = {
144471
+ name: refactorName4,
144472
+ description: refactorDescription,
144473
+ kind: "refactor.inline.variable"
144474
+ };
144475
+ registerRefactor(refactorName4, {
144476
+ kinds: [inlineVariableAction.kind],
144477
+ getAvailableActions(context) {
144478
+ const {
144479
+ file,
144480
+ program,
144481
+ preferences,
144482
+ startPosition,
144483
+ triggerReason
144484
+ } = context;
144485
+ const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
144486
+ if (!info) {
144487
+ return emptyArray;
144488
+ }
144489
+ if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
144490
+ return [{
144491
+ name: refactorName4,
144492
+ description: refactorDescription,
144493
+ actions: [inlineVariableAction]
144494
+ }];
144495
+ }
144496
+ if (preferences.provideRefactorNotApplicableReason) {
144497
+ return [{
144498
+ name: refactorName4,
144499
+ description: refactorDescription,
144500
+ actions: [{
144501
+ ...inlineVariableAction,
144502
+ notApplicableReason: info.error
144503
+ }]
144504
+ }];
144505
+ }
144506
+ return emptyArray;
144507
+ },
144508
+ getEditsForAction(context, actionName2) {
144509
+ Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
144510
+ const { file, program, startPosition } = context;
144511
+ const info = getInliningInfo(
144512
+ file,
144513
+ startPosition,
144514
+ /*tryWithReferenceToken*/
144515
+ true,
144516
+ program
144517
+ );
144518
+ if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
144519
+ return void 0;
144520
+ }
144521
+ const { references, declaration, replacement } = info;
144522
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
144523
+ for (const node of references) {
144524
+ tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
144525
+ }
144526
+ tracker.delete(file, declaration);
144527
+ });
144528
+ return { edits };
144529
+ }
144530
+ });
144531
+ function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
144532
+ var _a, _b;
144533
+ const checker = program.getTypeChecker();
144534
+ const token = getTouchingPropertyName(file, startPosition);
144535
+ const parent2 = token.parent;
144536
+ if (!isIdentifier(token)) {
144537
+ return void 0;
144538
+ }
144539
+ if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
144540
+ if (((_a = checker.getMergedSymbol(parent2.symbol).declarations) == null ? void 0 : _a.length) !== 1) {
144541
+ return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
144542
+ }
144543
+ if (isDeclarationExported(parent2)) {
144544
+ return void 0;
144545
+ }
144546
+ const references = getReferenceNodes(parent2, checker, file);
144547
+ return references && { references, declaration: parent2, replacement: parent2.initializer };
144548
+ }
144549
+ if (tryWithReferenceToken) {
144550
+ let definition = checker.resolveName(
144551
+ token.text,
144552
+ token,
144553
+ 111551 /* Value */,
144554
+ /*excludeGlobals*/
144555
+ false
144556
+ );
144557
+ definition = definition && checker.getMergedSymbol(definition);
144558
+ if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
144559
+ return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
144560
+ }
144561
+ const declaration = definition.declarations[0];
144562
+ if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
144563
+ return void 0;
144564
+ }
144565
+ if (isDeclarationExported(declaration)) {
144566
+ return void 0;
144567
+ }
144568
+ const references = getReferenceNodes(declaration, checker, file);
144569
+ return references && { references, declaration, replacement: declaration.initializer };
144570
+ }
144571
+ return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
144572
+ }
144573
+ function isDeclarationExported(declaration) {
144574
+ const variableStatement = cast(declaration.parent.parent, isVariableStatement);
144575
+ return some(variableStatement.modifiers, isExportModifier);
144576
+ }
144577
+ function getReferenceNodes(declaration, checker, file) {
144578
+ const references = [];
144579
+ const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
144580
+ if (ts_FindAllReferences_exports.isWriteAccessForReference(ref) && !isShorthandPropertyAssignment(ref.parent)) {
144581
+ return true;
144582
+ }
144583
+ if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
144584
+ return true;
144585
+ }
144586
+ if (isTypeQueryNode(ref.parent)) {
144587
+ return true;
144588
+ }
144589
+ if (textRangeContainsPositionInclusive(declaration, ref.pos)) {
144590
+ return true;
144591
+ }
144592
+ references.push(ref);
144593
+ });
144594
+ return references.length === 0 || cannotInline ? void 0 : references;
144595
+ }
144596
+ function getReplacementExpression(reference, replacement) {
144597
+ replacement = getSynthesizedDeepClone(replacement);
144598
+ const { parent: parent2 } = reference;
144599
+ if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
144600
+ return factory.createParenthesizedExpression(replacement);
144601
+ }
144602
+ if (isFunctionLike(replacement) && (isCallLikeExpression(parent2) || isPropertyAccessExpression(parent2))) {
144603
+ return factory.createParenthesizedExpression(replacement);
144604
+ }
144605
+ if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
144606
+ return factory.createParenthesizedExpression(replacement);
144607
+ }
144608
+ if (isIdentifier(reference) && isShorthandPropertyAssignment(parent2)) {
144609
+ return factory.createPropertyAssignment(reference, replacement);
144610
+ }
144611
+ return replacement;
144612
+ }
144613
+
144614
+ // src/services/refactors/moveToNewFile.ts
144615
+ var refactorName5 = "Move to a new file";
144616
+ var description2 = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
144617
+ var moveToNewFileAction = {
144618
+ name: refactorName5,
144619
+ description: description2,
144620
+ kind: "refactor.move.newFile"
144621
+ };
144622
+ registerRefactor(refactorName5, {
144623
+ kinds: [moveToNewFileAction.kind],
144624
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
144625
+ const statements = getStatementsToMove(context);
144626
+ if (context.preferences.allowTextChangesInNewFiles && statements) {
144627
+ const file = context.file;
144628
+ const affectedTextRange = {
144629
+ start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
144630
+ end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
144631
+ };
144632
+ return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
144633
+ }
144634
+ if (context.preferences.provideRefactorNotApplicableReason) {
144635
+ return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
144636
+ }
144637
+ return emptyArray;
144638
+ },
144639
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
144640
+ Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
144641
+ const statements = Debug.checkDefined(getStatementsToMove(context));
144642
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context.file, context.program, statements, t, context.host, context, context.preferences));
144643
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
144644
+ }
144645
+ });
144646
+ function doChange4(oldFile, program, toMove, changes, host, context, preferences) {
144647
+ const checker = program.getTypeChecker();
144648
+ const usage = getUsageInfo(oldFile, toMove.all, checker);
144649
+ const newFilename = createNewFileName(oldFile, program, host, toMove);
144650
+ const newSourceFile = createFutureSourceFile(newFilename, oldFile.externalModuleIndicator ? 99 /* ESNext */ : oldFile.commonJsModuleIndicator ? 1 /* CommonJS */ : void 0, program, host);
144651
+ const importAdderForOldFile = ts_codefix_exports.createImportAdder(oldFile, context.program, context.preferences, context.host);
144652
+ const importAdderForNewFile = ts_codefix_exports.createImportAdder(newSourceFile, context.program, context.preferences, context.host);
144653
+ getNewStatementsAndRemoveFromOldFile(oldFile, newSourceFile, usage, changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile);
144654
+ addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
144655
+ }
144656
+
144853
144657
  // src/services/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts
144854
144658
  var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {};
144855
144659
 
@@ -154841,6 +154645,14 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
154841
154645
  entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
154842
154646
  break;
154843
154647
  case 3 /* CommonJS */:
154648
+ if (compilerOptions.verbatimModuleSyntax) {
154649
+ const prevValue2 = (entry.namedImports || (entry.namedImports = /* @__PURE__ */ new Map())).get(symbolName2);
154650
+ entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue2, addAsTypeOnly));
154651
+ } else {
154652
+ Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
154653
+ entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
154654
+ }
154655
+ break;
154844
154656
  case 2 /* Namespace */:
154845
154657
  Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
154846
154658
  entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
@@ -179780,7 +179592,6 @@ __export(ts_exports2, {
179780
179592
  loadWithModeAwareCache: () => loadWithModeAwareCache,
179781
179593
  makeIdentifierFromModuleName: () => makeIdentifierFromModuleName,
179782
179594
  makeImport: () => makeImport,
179783
- makeImportIfNecessary: () => makeImportIfNecessary,
179784
179595
  makeStringLiteral: () => makeStringLiteral,
179785
179596
  mangleScopedPackageName: () => mangleScopedPackageName,
179786
179597
  map: () => map,
@@ -194207,7 +194018,6 @@ if (typeof console !== "undefined") {
194207
194018
  loadWithModeAwareCache,
194208
194019
  makeIdentifierFromModuleName,
194209
194020
  makeImport,
194210
- makeImportIfNecessary,
194211
194021
  makeStringLiteral,
194212
194022
  mangleScopedPackageName,
194213
194023
  map,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.5.0-pr-55267-144",
5
+ "version": "5.5.0-pr-58321-7",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [