typescript 5.5.0-dev.20240425 → 5.5.0-dev.20240426

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240425`;
21
+ var version = `${versionMajorMinor}.0-dev.20240426`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -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);
@@ -9456,6 +9456,7 @@ declare namespace ts {
9456
9456
  interface EmitOutput {
9457
9457
  outputFiles: OutputFile[];
9458
9458
  emitSkipped: boolean;
9459
+ diagnostics: readonly Diagnostic[];
9459
9460
  }
9460
9461
  interface OutputFile {
9461
9462
  name: string;
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,
@@ -2361,7 +2360,7 @@ module.exports = __toCommonJS(typescript_exports);
2361
2360
 
2362
2361
  // src/compiler/corePublic.ts
2363
2362
  var versionMajorMinor = "5.5";
2364
- var version = `${versionMajorMinor}.0-dev.20240425`;
2363
+ var version = `${versionMajorMinor}.0-dev.20240426`;
2365
2364
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2366
2365
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2367
2366
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -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);
@@ -137095,9 +137096,6 @@ function getModuleSpecifierResolverHost(program, host) {
137095
137096
  function moduleResolutionUsesNodeModules(moduleResolution) {
137096
137097
  return moduleResolution === 2 /* Node10 */ || moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
137097
137098
  }
137098
- function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
137099
- return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : void 0;
137100
- }
137101
137099
  function makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference, isTypeOnly) {
137102
137100
  return factory.createImportDeclaration(
137103
137101
  /*modifiers*/
@@ -137111,10 +137109,10 @@ function makeImport(defaultImport, namedImports, moduleSpecifier, quotePreferenc
137111
137109
  function makeStringLiteral(text, quotePreference) {
137112
137110
  return factory.createStringLiteral(text, quotePreference === 0 /* Single */);
137113
137111
  }
137114
- var QuotePreference = /* @__PURE__ */ ((QuotePreference7) => {
137115
- QuotePreference7[QuotePreference7["Single"] = 0] = "Single";
137116
- QuotePreference7[QuotePreference7["Double"] = 1] = "Double";
137117
- return QuotePreference7;
137112
+ var QuotePreference = /* @__PURE__ */ ((QuotePreference6) => {
137113
+ QuotePreference6[QuotePreference6["Single"] = 0] = "Single";
137114
+ QuotePreference6[QuotePreference6["Double"] = 1] = "Double";
137115
+ return QuotePreference6;
137118
137116
  })(QuotePreference || {});
137119
137117
  function quotePreferenceFromString(str, sourceFile) {
137120
137118
  return isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */;
@@ -142697,16 +142695,16 @@ function cleanText(text) {
142697
142695
  var ts_refactor_exports = {};
142698
142696
  __export(ts_refactor_exports, {
142699
142697
  addExportToChanges: () => addExportToChanges,
142700
- addExports: () => addExports,
142698
+ addImportsForMovedSymbols: () => addImportsForMovedSymbols,
142701
142699
  addNewFileToTsconfig: () => addNewFileToTsconfig,
142702
142700
  addOrRemoveBracesToArrowFunction: () => ts_refactor_addOrRemoveBracesToArrowFunction_exports,
142701
+ addTargetFileImports: () => addTargetFileImports,
142703
142702
  containsJsx: () => containsJsx,
142704
142703
  convertArrowFunctionOrFunctionExpression: () => ts_refactor_convertArrowFunctionOrFunctionExpression_exports,
142705
142704
  convertParamsToDestructuredObject: () => ts_refactor_convertParamsToDestructuredObject_exports,
142706
142705
  convertStringOrTemplateLiteral: () => ts_refactor_convertStringOrTemplateLiteral_exports,
142707
142706
  convertToOptionalChainExpression: () => ts_refactor_convertToOptionalChainExpression_exports,
142708
142707
  createNewFileName: () => createNewFileName,
142709
- createOldFileImportsFromTargetFile: () => createOldFileImportsFromTargetFile,
142710
142708
  deleteMovedStatements: () => deleteMovedStatements,
142711
142709
  deleteUnusedImports: () => deleteUnusedImports,
142712
142710
  deleteUnusedOldImports: () => deleteUnusedOldImports,
@@ -142717,13 +142715,13 @@ __export(ts_refactor_exports, {
142717
142715
  generateGetAccessorAndSetAccessor: () => ts_refactor_generateGetAccessorAndSetAccessor_exports,
142718
142716
  getApplicableRefactors: () => getApplicableRefactors,
142719
142717
  getEditsForRefactor: () => getEditsForRefactor,
142718
+ getNewStatementsAndRemoveFromOldFile: () => getNewStatementsAndRemoveFromOldFile,
142720
142719
  getStatementsToMove: () => getStatementsToMove,
142721
142720
  getTopLevelDeclarationStatement: () => getTopLevelDeclarationStatement,
142722
142721
  getUsageInfo: () => getUsageInfo,
142723
142722
  inferFunctionReturnType: () => ts_refactor_inferFunctionReturnType_exports,
142724
142723
  isRefactorErrorInfo: () => isRefactorErrorInfo,
142725
142724
  isTopLevelDeclaration: () => isTopLevelDeclaration,
142726
- makeImportOrRequire: () => makeImportOrRequire,
142727
142725
  moduleSpecifierFromImport: () => moduleSpecifierFromImport,
142728
142726
  nameOfTopLevelDeclaration: () => nameOfTopLevelDeclaration,
142729
142727
  refactorKindBeginsWith: () => refactorKindBeginsWith,
@@ -143595,282 +143593,12 @@ function getExpandedSelectionNode(firstType, enclosingNode) {
143595
143593
  }) ?? firstType;
143596
143594
  }
143597
143595
 
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
143596
  // src/services/refactors/moveToFile.ts
143869
143597
  var refactorNameForMoveToFile = "Move to file";
143870
- var description2 = getLocaleSpecificMessage(Diagnostics.Move_to_file);
143598
+ var description = getLocaleSpecificMessage(Diagnostics.Move_to_file);
143871
143599
  var moveToFileAction = {
143872
143600
  name: "Move to file",
143873
- description: description2,
143601
+ description,
143874
143602
  kind: "refactor.move.file"
143875
143603
  };
143876
143604
  registerRefactor(refactorNameForMoveToFile, {
@@ -143893,10 +143621,10 @@ registerRefactor(refactorNameForMoveToFile, {
143893
143621
  start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
143894
143622
  end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
143895
143623
  };
143896
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
143624
+ return [{ name: refactorNameForMoveToFile, description, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
143897
143625
  }
143898
143626
  if (context.preferences.provideRefactorNotApplicableReason) {
143899
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143627
+ return [{ name: refactorNameForMoveToFile, description, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143900
143628
  }
143901
143629
  return emptyArray;
143902
143630
  },
@@ -143910,7 +143638,7 @@ registerRefactor(refactorNameForMoveToFile, {
143910
143638
  if (host.fileExists(targetFile) && program.getSourceFile(targetFile) === void 0) {
143911
143639
  return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_statements_to_the_selected_file));
143912
143640
  }
143913
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
143641
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
143914
143642
  return { edits, renameFilename: void 0, renameLocation: void 0 };
143915
143643
  }
143916
143644
  return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid));
@@ -143919,144 +143647,46 @@ registerRefactor(refactorNameForMoveToFile, {
143919
143647
  function error(notApplicableReason) {
143920
143648
  return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason };
143921
143649
  }
143922
- function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
143650
+ function doChange3(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
143923
143651
  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));
143652
+ const isForNewFile = !host.fileExists(targetFile);
143653
+ const targetSourceFile = isForNewFile ? createFutureSourceFile(targetFile, oldFile.externalModuleIndicator ? 99 /* ESNext */ : oldFile.commonJsModuleIndicator ? 1 /* CommonJS */ : void 0, program, host) : Debug.checkDefined(program.getSourceFile(targetFile));
143654
+ const importAdderForOldFile = ts_codefix_exports.createImportAdder(oldFile, context.program, context.preferences, context.host);
143655
+ const importAdderForNewFile = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host);
143656
+ getNewStatementsAndRemoveFromOldFile(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, isForNewFile ? void 0 : getExistingLocals(targetSourceFile, toMove.all, checker)), changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile);
143657
+ if (isForNewFile) {
143926
143658
  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
143659
  }
143932
143660
  }
143933
- function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) {
143661
+ function getNewStatementsAndRemoveFromOldFile(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile) {
143934
143662
  const checker = program.getTypeChecker();
143935
143663
  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);
143664
+ const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(targetFile.fileName, program, host, !!oldFile.commonJsModuleIndicator);
143942
143665
  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,
143666
+ addImportsForMovedSymbols(usage.oldFileImportsFromTargetFile, targetFile.fileName, importAdderForOldFile, program);
143667
+ deleteUnusedOldImports(oldFile, toMove.all, usage.unusedImportsFromOldFile, importAdderForOldFile);
143668
+ importAdderForOldFile.writeFixes(changes, quotePreference);
143669
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
143670
+ updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, targetFile.fileName, quotePreference);
143671
+ addExportsInOldFile(oldFile, usage.targetFileImportsFromOldFile, changes, useEsModuleSyntax);
143672
+ addTargetFileImports(oldFile, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile, checker, program, importAdderForNewFile);
143673
+ if (!isFullSourceFile(targetFile) && prologueDirectives.length) {
143674
+ changes.insertStatementsInNewFile(targetFile.fileName, prologueDirectives, oldFile);
143675
+ }
143676
+ importAdderForNewFile.writeFixes(changes, quotePreference);
143677
+ const body = addExports(oldFile, toMove.all, arrayFrom(usage.oldFileImportsFromTargetFile.keys()), useEsModuleSyntax);
143678
+ if (isFullSourceFile(targetFile) && targetFile.statements.length > 0) {
143679
+ moveStatementsToTargetFile(changes, program, body, targetFile, toMove);
143680
+ } else if (isFullSourceFile(targetFile)) {
143681
+ changes.insertNodesAtEndOfFile(
143682
+ targetFile,
143683
+ body,
143949
143684
  /*blankLineBetween*/
143950
- true,
143951
- preferences
143685
+ false
143952
143686
  );
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
143687
  } 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
- }
143688
+ changes.insertStatementsInNewFile(targetFile.fileName, importAdderForNewFile.hasFixes() ? [4 /* NewLineTrivia */, ...body] : body, oldFile);
144029
143689
  }
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
143690
  }
144061
143691
  function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
144062
143692
  const cfg = program.getCompilerOptions().configFile;
@@ -144075,13 +143705,38 @@ function deleteMovedStatements(sourceFile, moved, changes) {
144075
143705
  changes.deleteNodeRangeExcludingEnd(sourceFile, first2, afterLast);
144076
143706
  }
144077
143707
  }
144078
- function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
143708
+ function deleteUnusedOldImports(oldFile, toMove, toDelete, importAdder) {
144079
143709
  for (const statement of oldFile.statements) {
144080
143710
  if (contains(toMove, statement))
144081
143711
  continue;
144082
- forEachImportInStatement(statement, (i) => deleteUnusedImports(oldFile, i, changes, (name) => toDelete.has(checker.getSymbolAtLocation(name))));
143712
+ forEachImportInStatement(statement, (i) => {
143713
+ forEachAliasDeclarationInImportOrRequire(i, (decl) => {
143714
+ if (toDelete.has(decl.symbol)) {
143715
+ importAdder.removeExistingImport(decl);
143716
+ }
143717
+ });
143718
+ });
144083
143719
  }
144084
143720
  }
143721
+ function addExportsInOldFile(oldFile, targetFileImportsFromOldFile, changes, useEsModuleSyntax) {
143722
+ const markSeenTop = nodeSeenTracker();
143723
+ targetFileImportsFromOldFile.forEach((_, symbol) => {
143724
+ if (!symbol.declarations) {
143725
+ return;
143726
+ }
143727
+ for (const decl of symbol.declarations) {
143728
+ if (!isTopLevelDeclaration(decl))
143729
+ continue;
143730
+ const name = nameOfTopLevelDeclaration(decl);
143731
+ if (!name)
143732
+ continue;
143733
+ const top = getTopLevelDeclarationStatement(decl);
143734
+ if (markSeenTop(top)) {
143735
+ addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
143736
+ }
143737
+ }
143738
+ });
143739
+ }
144085
143740
  function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols, targetFileName, quotePreference) {
144086
143741
  const checker = program.getTypeChecker();
144087
143742
  for (const sourceFile of program.getSourceFiles()) {
@@ -144220,45 +143875,39 @@ function forEachImportInStatement(statement, cb) {
144220
143875
  }
144221
143876
  }
144222
143877
  }
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);
143878
+ function forEachAliasDeclarationInImportOrRequire(importOrRequire, cb) {
143879
+ var _a, _b, _c, _d, _e;
143880
+ if (importOrRequire.kind === 272 /* ImportDeclaration */) {
143881
+ if ((_a = importOrRequire.importClause) == null ? void 0 : _a.name) {
143882
+ cb(importOrRequire.importClause);
144231
143883
  }
144232
- });
144233
- return makeImportOrRequire(sourceFile, defaultImport, imports, targetFileNameWithExtension, program, host, useEs6Imports, quotePreference);
143884
+ if (((_c = (_b = importOrRequire.importClause) == null ? void 0 : _b.namedBindings) == null ? void 0 : _c.kind) === 274 /* NamespaceImport */) {
143885
+ cb(importOrRequire.importClause.namedBindings);
143886
+ }
143887
+ if (((_e = (_d = importOrRequire.importClause) == null ? void 0 : _d.namedBindings) == null ? void 0 : _e.kind) === 275 /* NamedImports */) {
143888
+ for (const element of importOrRequire.importClause.namedBindings.elements) {
143889
+ cb(element);
143890
+ }
143891
+ }
143892
+ } else if (importOrRequire.kind === 271 /* ImportEqualsDeclaration */) {
143893
+ cb(importOrRequire);
143894
+ } else if (importOrRequire.kind === 260 /* VariableDeclaration */) {
143895
+ if (importOrRequire.name.kind === 80 /* Identifier */) {
143896
+ cb(importOrRequire);
143897
+ } else if (importOrRequire.name.kind === 206 /* ObjectBindingPattern */) {
143898
+ for (const element of importOrRequire.name.elements) {
143899
+ if (isIdentifier(element.name)) {
143900
+ cb(element);
143901
+ }
143902
+ }
143903
+ }
143904
+ }
144234
143905
  }
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;
143906
+ function addImportsForMovedSymbols(symbols, targetFileName, importAdder, program) {
143907
+ for (const [symbol, isValidTypeOnlyUseSite] of symbols) {
143908
+ const symbolName2 = getNameForExportedSymbol(symbol, getEmitScriptTarget(program.getCompilerOptions()));
143909
+ const exportKind = symbol.name === "default" && symbol.parent ? 1 /* Default */ : 0 /* Named */;
143910
+ importAdder.addImportForNonExistentExport(symbolName2, targetFileName, exportKind, symbol.flags, isValidTypeOnlyUseSite);
144262
143911
  }
144263
143912
  }
144264
143913
  function makeVariableStatement(name, type, initializer, flags = 2 /* Const */) {
@@ -144278,7 +143927,7 @@ function addExports(sourceFile, toMove, needExport, useEs6Exports) {
144278
143927
  return flatMap(toMove, (statement) => {
144279
143928
  if (isTopLevelDeclarationStatement(statement) && !isExported(sourceFile, statement, useEs6Exports) && forEachTopLevelDeclaration(statement, (d) => {
144280
143929
  var _a;
144281
- return needExport.has(Debug.checkDefined((_a = tryCast(d, canHaveSymbol)) == null ? void 0 : _a.symbol));
143930
+ return needExport.includes(Debug.checkDefined((_a = tryCast(d, canHaveSymbol)) == null ? void 0 : _a.symbol));
144282
143931
  })) {
144283
143932
  const exports2 = addExport(getSynthesizedDeepClone(statement), useEs6Exports);
144284
143933
  if (exports2)
@@ -144295,86 +143944,17 @@ function isExported(sourceFile, decl, useEs6Exports, name) {
144295
143944
  return !!sourceFile.symbol && !!sourceFile.symbol.exports && getNamesToExportInCommonJS(decl).some((name2) => sourceFile.symbol.exports.has(escapeLeadingUnderscores(name2)));
144296
143945
  }
144297
143946
  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);
143947
+ if (importDecl.kind === 272 /* ImportDeclaration */ && importDecl.importClause) {
143948
+ const { name, namedBindings } = importDecl.importClause;
143949
+ if ((!name || isUnused(name)) && (!namedBindings || namedBindings.kind === 275 /* NamedImports */ && namedBindings.elements.length !== 0 && namedBindings.elements.every((e) => isUnused(e.name)))) {
143950
+ return changes.delete(sourceFile, importDecl);
144325
143951
  }
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
143952
  }
143953
+ forEachAliasDeclarationInImportOrRequire(importDecl, (i) => {
143954
+ if (i.name && isIdentifier(i.name) && isUnused(i.name)) {
143955
+ changes.delete(sourceFile, i);
143956
+ }
143957
+ });
144378
143958
  }
144379
143959
  function isTopLevelDeclarationStatement(node) {
144380
143960
  Debug.assert(isSourceFile(node.parent), "Node parent should be a SourceFile");
@@ -144598,12 +144178,13 @@ function isPureImport(node) {
144598
144178
  }
144599
144179
  }
144600
144180
  function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PURE__ */ new Set()) {
144181
+ var _a;
144601
144182
  const movedSymbols = /* @__PURE__ */ new Set();
144602
144183
  const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map();
144603
- const targetFileImportsFromOldFile = /* @__PURE__ */ new Set();
144184
+ const targetFileImportsFromOldFile = /* @__PURE__ */ new Map();
144604
144185
  const jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx(toMove));
144605
144186
  if (jsxNamespaceSymbol) {
144606
- oldImportsNeededByTargetFile.set(jsxNamespaceSymbol, false);
144187
+ 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
144188
  }
144608
144189
  for (const statement of toMove) {
144609
144190
  forEachTopLevelDeclaration(statement, (decl) => {
@@ -144623,9 +144204,12 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
144623
144204
  for (const decl of symbol.declarations) {
144624
144205
  if (isInImport(decl)) {
144625
144206
  const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol);
144626
- oldImportsNeededByTargetFile.set(symbol, prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite);
144207
+ oldImportsNeededByTargetFile.set(symbol, [
144208
+ prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite,
144209
+ tryCast(decl, (d) => isImportSpecifier(d) || isImportClause(d) || isNamespaceImport(d) || isImportEqualsDeclaration(d) || isBindingElement(d) || isVariableDeclaration(d))
144210
+ ]);
144627
144211
  } else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) {
144628
- targetFileImportsFromOldFile.add(symbol);
144212
+ targetFileImportsFromOldFile.set(symbol, isValidTypeOnlyUseSite);
144629
144213
  }
144630
144214
  }
144631
144215
  });
@@ -144633,16 +144217,16 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
144633
144217
  for (const unusedImport of oldImportsNeededByTargetFile.keys()) {
144634
144218
  unusedImportsFromOldFile.add(unusedImport);
144635
144219
  }
144636
- const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set();
144220
+ const oldFileImportsFromTargetFile = /* @__PURE__ */ new Map();
144637
144221
  for (const statement of oldFile.statements) {
144638
144222
  if (contains(toMove, statement))
144639
144223
  continue;
144640
144224
  if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) {
144641
144225
  unusedImportsFromOldFile.delete(jsxNamespaceSymbol);
144642
144226
  }
144643
- forEachReference(statement, checker, (symbol) => {
144227
+ forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
144644
144228
  if (movedSymbols.has(symbol))
144645
- oldFileImportsFromTargetFile.add(symbol);
144229
+ oldFileImportsFromTargetFile.set(symbol, isValidTypeOnlyUseSite);
144646
144230
  unusedImportsFromOldFile.delete(symbol);
144647
144231
  });
144648
144232
  }
@@ -144850,6 +144434,218 @@ function getExistingLocals(sourceFile, statements, checker) {
144850
144434
  return existingLocals;
144851
144435
  }
144852
144436
 
144437
+ // src/services/refactors/helpers.ts
144438
+ function isRefactorErrorInfo(info) {
144439
+ return info.error !== void 0;
144440
+ }
144441
+ function refactorKindBeginsWith(known, requested) {
144442
+ if (!requested)
144443
+ return true;
144444
+ return known.substr(0, requested.length) === requested;
144445
+ }
144446
+ function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFile, checker, program, importAdder) {
144447
+ importsToCopy.forEach(([isValidTypeOnlyUseSite, declaration], symbol) => {
144448
+ var _a;
144449
+ const targetSymbol = skipAlias(symbol, checker);
144450
+ if (checker.isUnknownSymbol(targetSymbol)) {
144451
+ importAdder.addVerbatimImport(Debug.checkDefined(declaration ?? findAncestor((_a = symbol.declarations) == null ? void 0 : _a[0], isAnyImportOrRequireStatement)));
144452
+ } else {
144453
+ importAdder.addImportFromExportedSymbol(targetSymbol, isValidTypeOnlyUseSite, declaration);
144454
+ }
144455
+ });
144456
+ addImportsForMovedSymbols(targetFileImportsFromOldFile, oldFile.fileName, importAdder, program);
144457
+ }
144458
+
144459
+ // src/services/refactors/inlineVariable.ts
144460
+ var refactorName4 = "Inline variable";
144461
+ var refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
144462
+ var inlineVariableAction = {
144463
+ name: refactorName4,
144464
+ description: refactorDescription,
144465
+ kind: "refactor.inline.variable"
144466
+ };
144467
+ registerRefactor(refactorName4, {
144468
+ kinds: [inlineVariableAction.kind],
144469
+ getAvailableActions(context) {
144470
+ const {
144471
+ file,
144472
+ program,
144473
+ preferences,
144474
+ startPosition,
144475
+ triggerReason
144476
+ } = context;
144477
+ const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
144478
+ if (!info) {
144479
+ return emptyArray;
144480
+ }
144481
+ if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
144482
+ return [{
144483
+ name: refactorName4,
144484
+ description: refactorDescription,
144485
+ actions: [inlineVariableAction]
144486
+ }];
144487
+ }
144488
+ if (preferences.provideRefactorNotApplicableReason) {
144489
+ return [{
144490
+ name: refactorName4,
144491
+ description: refactorDescription,
144492
+ actions: [{
144493
+ ...inlineVariableAction,
144494
+ notApplicableReason: info.error
144495
+ }]
144496
+ }];
144497
+ }
144498
+ return emptyArray;
144499
+ },
144500
+ getEditsForAction(context, actionName2) {
144501
+ Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
144502
+ const { file, program, startPosition } = context;
144503
+ const info = getInliningInfo(
144504
+ file,
144505
+ startPosition,
144506
+ /*tryWithReferenceToken*/
144507
+ true,
144508
+ program
144509
+ );
144510
+ if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
144511
+ return void 0;
144512
+ }
144513
+ const { references, declaration, replacement } = info;
144514
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
144515
+ for (const node of references) {
144516
+ tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
144517
+ }
144518
+ tracker.delete(file, declaration);
144519
+ });
144520
+ return { edits };
144521
+ }
144522
+ });
144523
+ function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
144524
+ var _a, _b;
144525
+ const checker = program.getTypeChecker();
144526
+ const token = getTouchingPropertyName(file, startPosition);
144527
+ const parent2 = token.parent;
144528
+ if (!isIdentifier(token)) {
144529
+ return void 0;
144530
+ }
144531
+ if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
144532
+ if (((_a = checker.getMergedSymbol(parent2.symbol).declarations) == null ? void 0 : _a.length) !== 1) {
144533
+ return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
144534
+ }
144535
+ if (isDeclarationExported(parent2)) {
144536
+ return void 0;
144537
+ }
144538
+ const references = getReferenceNodes(parent2, checker, file);
144539
+ return references && { references, declaration: parent2, replacement: parent2.initializer };
144540
+ }
144541
+ if (tryWithReferenceToken) {
144542
+ let definition = checker.resolveName(
144543
+ token.text,
144544
+ token,
144545
+ 111551 /* Value */,
144546
+ /*excludeGlobals*/
144547
+ false
144548
+ );
144549
+ definition = definition && checker.getMergedSymbol(definition);
144550
+ if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
144551
+ return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
144552
+ }
144553
+ const declaration = definition.declarations[0];
144554
+ if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
144555
+ return void 0;
144556
+ }
144557
+ if (isDeclarationExported(declaration)) {
144558
+ return void 0;
144559
+ }
144560
+ const references = getReferenceNodes(declaration, checker, file);
144561
+ return references && { references, declaration, replacement: declaration.initializer };
144562
+ }
144563
+ return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
144564
+ }
144565
+ function isDeclarationExported(declaration) {
144566
+ const variableStatement = cast(declaration.parent.parent, isVariableStatement);
144567
+ return some(variableStatement.modifiers, isExportModifier);
144568
+ }
144569
+ function getReferenceNodes(declaration, checker, file) {
144570
+ const references = [];
144571
+ const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
144572
+ if (ts_FindAllReferences_exports.isWriteAccessForReference(ref) && !isShorthandPropertyAssignment(ref.parent)) {
144573
+ return true;
144574
+ }
144575
+ if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
144576
+ return true;
144577
+ }
144578
+ if (isTypeQueryNode(ref.parent)) {
144579
+ return true;
144580
+ }
144581
+ if (textRangeContainsPositionInclusive(declaration, ref.pos)) {
144582
+ return true;
144583
+ }
144584
+ references.push(ref);
144585
+ });
144586
+ return references.length === 0 || cannotInline ? void 0 : references;
144587
+ }
144588
+ function getReplacementExpression(reference, replacement) {
144589
+ replacement = getSynthesizedDeepClone(replacement);
144590
+ const { parent: parent2 } = reference;
144591
+ if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
144592
+ return factory.createParenthesizedExpression(replacement);
144593
+ }
144594
+ if (isFunctionLike(replacement) && (isCallLikeExpression(parent2) || isPropertyAccessExpression(parent2))) {
144595
+ return factory.createParenthesizedExpression(replacement);
144596
+ }
144597
+ if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
144598
+ return factory.createParenthesizedExpression(replacement);
144599
+ }
144600
+ if (isIdentifier(reference) && isShorthandPropertyAssignment(parent2)) {
144601
+ return factory.createPropertyAssignment(reference, replacement);
144602
+ }
144603
+ return replacement;
144604
+ }
144605
+
144606
+ // src/services/refactors/moveToNewFile.ts
144607
+ var refactorName5 = "Move to a new file";
144608
+ var description2 = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
144609
+ var moveToNewFileAction = {
144610
+ name: refactorName5,
144611
+ description: description2,
144612
+ kind: "refactor.move.newFile"
144613
+ };
144614
+ registerRefactor(refactorName5, {
144615
+ kinds: [moveToNewFileAction.kind],
144616
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
144617
+ const statements = getStatementsToMove(context);
144618
+ if (context.preferences.allowTextChangesInNewFiles && statements) {
144619
+ const file = context.file;
144620
+ const affectedTextRange = {
144621
+ start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
144622
+ end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
144623
+ };
144624
+ return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
144625
+ }
144626
+ if (context.preferences.provideRefactorNotApplicableReason) {
144627
+ return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
144628
+ }
144629
+ return emptyArray;
144630
+ },
144631
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
144632
+ Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
144633
+ const statements = Debug.checkDefined(getStatementsToMove(context));
144634
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context.file, context.program, statements, t, context.host, context, context.preferences));
144635
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
144636
+ }
144637
+ });
144638
+ function doChange4(oldFile, program, toMove, changes, host, context, preferences) {
144639
+ const checker = program.getTypeChecker();
144640
+ const usage = getUsageInfo(oldFile, toMove.all, checker);
144641
+ const newFilename = createNewFileName(oldFile, program, host, toMove);
144642
+ const newSourceFile = createFutureSourceFile(newFilename, oldFile.externalModuleIndicator ? 99 /* ESNext */ : oldFile.commonJsModuleIndicator ? 1 /* CommonJS */ : void 0, program, host);
144643
+ const importAdderForOldFile = ts_codefix_exports.createImportAdder(oldFile, context.program, context.preferences, context.host);
144644
+ const importAdderForNewFile = ts_codefix_exports.createImportAdder(newSourceFile, context.program, context.preferences, context.host);
144645
+ getNewStatementsAndRemoveFromOldFile(oldFile, newSourceFile, usage, changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile);
144646
+ addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
144647
+ }
144648
+
144853
144649
  // src/services/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts
144854
144650
  var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {};
144855
144651
 
@@ -154841,6 +154637,14 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
154841
154637
  entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
154842
154638
  break;
154843
154639
  case 3 /* CommonJS */:
154640
+ if (compilerOptions.verbatimModuleSyntax) {
154641
+ const prevValue2 = (entry.namedImports || (entry.namedImports = /* @__PURE__ */ new Map())).get(symbolName2);
154642
+ entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue2, addAsTypeOnly));
154643
+ } else {
154644
+ Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
154645
+ entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
154646
+ }
154647
+ break;
154844
154648
  case 2 /* Namespace */:
154845
154649
  Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
154846
154650
  entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
@@ -179780,7 +179584,6 @@ __export(ts_exports2, {
179780
179584
  loadWithModeAwareCache: () => loadWithModeAwareCache,
179781
179585
  makeIdentifierFromModuleName: () => makeIdentifierFromModuleName,
179782
179586
  makeImport: () => makeImport,
179783
- makeImportIfNecessary: () => makeImportIfNecessary,
179784
179587
  makeStringLiteral: () => makeStringLiteral,
179785
179588
  mangleScopedPackageName: () => mangleScopedPackageName,
179786
179589
  map: () => map,
@@ -194207,7 +194010,6 @@ if (typeof console !== "undefined") {
194207
194010
  loadWithModeAwareCache,
194208
194011
  makeIdentifierFromModuleName,
194209
194012
  makeImport,
194210
- makeImportIfNecessary,
194211
194013
  makeStringLiteral,
194212
194014
  mangleScopedPackageName,
194213
194015
  map,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.5.0-dev.20240425",
5
+ "version": "5.5.0-dev.20240426",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -110,5 +110,5 @@
110
110
  "node": "20.1.0",
111
111
  "npm": "8.19.4"
112
112
  },
113
- "gitHead": "9504b7576a6489a3d5149db451b6ec8f772d67d4"
113
+ "gitHead": "04963ee796dc3716e5c18a28a5950f4ca8b900e1"
114
114
  }