typescript 5.5.0-dev.20240425 → 5.5.0-dev.20240427

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/typescript.js CHANGED
@@ -511,6 +511,7 @@ __export(typescript_exports, {
511
511
  defaultMaximumTruncationLength: () => defaultMaximumTruncationLength,
512
512
  diagnosticCategoryName: () => diagnosticCategoryName,
513
513
  diagnosticToString: () => diagnosticToString,
514
+ diagnosticsEqualityComparer: () => diagnosticsEqualityComparer,
514
515
  directoryProbablyExists: () => directoryProbablyExists,
515
516
  directorySeparator: () => directorySeparator,
516
517
  displayPart: () => displayPart,
@@ -1894,7 +1895,6 @@ __export(typescript_exports, {
1894
1895
  loadWithModeAwareCache: () => loadWithModeAwareCache,
1895
1896
  makeIdentifierFromModuleName: () => makeIdentifierFromModuleName,
1896
1897
  makeImport: () => makeImport,
1897
- makeImportIfNecessary: () => makeImportIfNecessary,
1898
1898
  makeStringLiteral: () => makeStringLiteral,
1899
1899
  mangleScopedPackageName: () => mangleScopedPackageName,
1900
1900
  map: () => map,
@@ -2361,7 +2361,7 @@ module.exports = __toCommonJS(typescript_exports);
2361
2361
 
2362
2362
  // src/compiler/corePublic.ts
2363
2363
  var versionMajorMinor = "5.5";
2364
- var version = `${versionMajorMinor}.0-dev.20240425`;
2364
+ var version = `${versionMajorMinor}.0-dev.20240427`;
2365
2365
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2366
2366
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2367
2367
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -2881,13 +2881,23 @@ function deduplicateSorted(array, comparer) {
2881
2881
  function createSortedArray() {
2882
2882
  return [];
2883
2883
  }
2884
- function insertSorted(array, insert, compare, allowDuplicates) {
2884
+ function insertSorted(array, insert, compare, equalityComparer, allowDuplicates) {
2885
2885
  if (array.length === 0) {
2886
2886
  array.push(insert);
2887
2887
  return true;
2888
2888
  }
2889
2889
  const insertIndex = binarySearch(array, insert, identity, compare);
2890
2890
  if (insertIndex < 0) {
2891
+ if (equalityComparer && !allowDuplicates) {
2892
+ const idx = ~insertIndex;
2893
+ if (idx > 0 && equalityComparer(insert, array[idx - 1])) {
2894
+ return false;
2895
+ }
2896
+ if (idx < array.length && equalityComparer(insert, array[idx])) {
2897
+ array.splice(idx, 1, insert);
2898
+ return true;
2899
+ }
2900
+ }
2891
2901
  array.splice(~insertIndex, 0, insert);
2892
2902
  return true;
2893
2903
  }
@@ -7285,12 +7295,15 @@ var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarge
7285
7295
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ArrowFunctions"] = 2 /* ES2015 */] = "ArrowFunctions";
7286
7296
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BlockScopedVariables"] = 2 /* ES2015 */] = "BlockScopedVariables";
7287
7297
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectAssign"] = 2 /* ES2015 */] = "ObjectAssign";
7298
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsUnicode"] = 2 /* ES2015 */] = "RegularExpressionFlagsUnicode";
7299
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsSticky"] = 2 /* ES2015 */] = "RegularExpressionFlagsSticky";
7288
7300
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Exponentiation"] = 3 /* ES2016 */] = "Exponentiation";
7289
7301
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncFunctions"] = 4 /* ES2017 */] = "AsyncFunctions";
7290
7302
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForAwaitOf"] = 5 /* ES2018 */] = "ForAwaitOf";
7291
7303
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncGenerators"] = 5 /* ES2018 */] = "AsyncGenerators";
7292
7304
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncIteration"] = 5 /* ES2018 */] = "AsyncIteration";
7293
7305
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectSpreadRest"] = 5 /* ES2018 */] = "ObjectSpreadRest";
7306
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsDotAll"] = 5 /* ES2018 */] = "RegularExpressionFlagsDotAll";
7294
7307
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindinglessCatch"] = 6 /* ES2019 */] = "BindinglessCatch";
7295
7308
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BigInt"] = 7 /* ES2020 */] = "BigInt";
7296
7309
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["NullishCoalesce"] = 7 /* ES2020 */] = "NullishCoalesce";
@@ -7299,9 +7312,11 @@ var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarge
7299
7312
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TopLevelAwait"] = 9 /* ES2022 */] = "TopLevelAwait";
7300
7313
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassFields"] = 9 /* ES2022 */] = "ClassFields";
7301
7314
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["PrivateNamesAndClassStaticBlocks"] = 9 /* ES2022 */] = "PrivateNamesAndClassStaticBlocks";
7315
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsHasIndices"] = 9 /* ES2022 */] = "RegularExpressionFlagsHasIndices";
7302
7316
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ShebangComments"] = 99 /* ESNext */] = "ShebangComments";
7303
7317
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["UsingAndAwaitUsing"] = 99 /* ESNext */] = "UsingAndAwaitUsing";
7304
7318
  LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassAndClassElementDecorators"] = 99 /* ESNext */] = "ClassAndClassElementDecorators";
7319
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RegularExpressionFlagsUnicodeSets"] = 99 /* ESNext */] = "RegularExpressionFlagsUnicodeSets";
7305
7320
  return LanguageFeatureMinimumTarget2;
7306
7321
  })(LanguageFeatureMinimumTarget || {});
7307
7322
  var ExternalEmitHelpers = /* @__PURE__ */ ((ExternalEmitHelpers2) => {
@@ -11064,6 +11079,7 @@ var Diagnostics = {
11064
11079
  Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files: diag(6719, 3 /* Message */, "Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files_6719", "Require sufficient annotation on exports so other tools can trivially generate declaration files."),
11065
11080
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
11066
11081
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
11082
+ Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported: diag(6805, 3 /* Message */, "Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported_6805", "Disable full type checking (only critical parse and emit errors will be reported)."),
11067
11083
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
11068
11084
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
11069
11085
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -11716,14 +11732,11 @@ var charToRegExpFlag = new Map(Object.entries({
11716
11732
  y: 128 /* Sticky */
11717
11733
  }));
11718
11734
  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 */]
11735
+ [1 /* HasIndices */, 9 /* RegularExpressionFlagsHasIndices */],
11736
+ [16 /* DotAll */, 5 /* RegularExpressionFlagsDotAll */],
11737
+ [32 /* Unicode */, 2 /* RegularExpressionFlagsUnicode */],
11738
+ [64 /* UnicodeSets */, 99 /* RegularExpressionFlagsUnicodeSets */],
11739
+ [128 /* Sticky */, 2 /* RegularExpressionFlagsSticky */]
11727
11740
  ]);
11728
11741
  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
11742
  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 +13483,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13470
13483
  error2(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
13471
13484
  } else {
13472
13485
  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
- }
13486
+ checkRegularExpressionFlagAvailable(flag, p);
13477
13487
  }
13478
13488
  }
13479
13489
  p++;
@@ -13705,10 +13715,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
13705
13715
  error2(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
13706
13716
  } else {
13707
13717
  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
- }
13718
+ checkRegularExpressionFlagAvailable(flag, pos);
13712
13719
  }
13713
13720
  pos++;
13714
13721
  }
@@ -14315,6 +14322,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
14315
14322
  }
14316
14323
  });
14317
14324
  }
14325
+ function checkRegularExpressionFlagAvailable(flag, pos2) {
14326
+ const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
14327
+ if (availableFrom && languageVersion < availableFrom) {
14328
+ error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos2, 1, getNameOfScriptTarget(availableFrom));
14329
+ }
14330
+ }
14318
14331
  }
14319
14332
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
14320
14333
  const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
@@ -14706,7 +14719,7 @@ function isExternalModuleNameRelative(moduleName) {
14706
14719
  return pathIsRelative(moduleName) || isRootedDiskPath(moduleName);
14707
14720
  }
14708
14721
  function sortAndDeduplicateDiagnostics(diagnostics) {
14709
- return sortAndDeduplicate(diagnostics, compareDiagnostics);
14722
+ return sortAndDeduplicate(diagnostics, compareDiagnostics, diagnosticsEqualityComparer);
14710
14723
  }
14711
14724
  function getDefaultLibFileName(options) {
14712
14725
  switch (getEmitScriptTarget(options)) {
@@ -19830,6 +19843,9 @@ function createDiagnosticCollection() {
19830
19843
  if (result >= 0) {
19831
19844
  return diagnostics[result];
19832
19845
  }
19846
+ if (~result > 0 && diagnosticsEqualityComparer(diagnostic, diagnostics[~result - 1])) {
19847
+ return diagnostics[~result - 1];
19848
+ }
19833
19849
  return void 0;
19834
19850
  }
19835
19851
  function add(diagnostic) {
@@ -19848,7 +19864,7 @@ function createDiagnosticCollection() {
19848
19864
  }
19849
19865
  diagnostics = nonFileDiagnostics;
19850
19866
  }
19851
- insertSorted(diagnostics, diagnostic, compareDiagnosticsSkipRelatedInformation);
19867
+ insertSorted(diagnostics, diagnostic, compareDiagnosticsSkipRelatedInformation, diagnosticsEqualityComparer);
19852
19868
  }
19853
19869
  function getGlobalDiagnostics() {
19854
19870
  hasReadNonFileDiagnostics = true;
@@ -21616,7 +21632,7 @@ function compareRelatedInformation(d1, d2) {
21616
21632
  return 0 /* EqualTo */;
21617
21633
  }
21618
21634
  if (d1.relatedInformation && d2.relatedInformation) {
21619
- return compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || forEach(d1.relatedInformation, (d1i, index) => {
21635
+ return compareValues(d2.relatedInformation.length, d1.relatedInformation.length) || forEach(d1.relatedInformation, (d1i, index) => {
21620
21636
  const d2i = d2.relatedInformation[index];
21621
21637
  return compareDiagnostics(d1i, d2i);
21622
21638
  }) || 0 /* EqualTo */;
@@ -21626,38 +21642,78 @@ function compareRelatedInformation(d1, d2) {
21626
21642
  function compareMessageText(t1, t2) {
21627
21643
  if (typeof t1 === "string" && typeof t2 === "string") {
21628
21644
  return compareStringsCaseSensitive(t1, t2);
21629
- } else if (typeof t1 === "string") {
21630
- return -1 /* LessThan */;
21631
- } else if (typeof t2 === "string") {
21632
- return 1 /* GreaterThan */;
21633
21645
  }
21634
- let res = compareStringsCaseSensitive(t1.messageText, t2.messageText);
21646
+ if (typeof t1 === "string") {
21647
+ t1 = { messageText: t1 };
21648
+ }
21649
+ if (typeof t2 === "string") {
21650
+ t2 = { messageText: t2 };
21651
+ }
21652
+ const res = compareStringsCaseSensitive(t1.messageText, t2.messageText);
21635
21653
  if (res) {
21636
21654
  return res;
21637
21655
  }
21638
- if (!t1.next && !t2.next) {
21656
+ return compareMessageChain(t1.next, t2.next);
21657
+ }
21658
+ function compareMessageChain(c1, c2) {
21659
+ if (c1 === void 0 && c2 === void 0) {
21639
21660
  return 0 /* EqualTo */;
21640
21661
  }
21641
- if (!t1.next) {
21662
+ if (c1 === void 0) {
21663
+ return 1 /* GreaterThan */;
21664
+ }
21665
+ if (c2 === void 0) {
21642
21666
  return -1 /* LessThan */;
21643
21667
  }
21644
- if (!t2.next) {
21668
+ return compareMessageChainSize(c1, c2) || compareMessageChainContent(c1, c2);
21669
+ }
21670
+ function compareMessageChainSize(c1, c2) {
21671
+ if (c1 === void 0 && c2 === void 0) {
21672
+ return 0 /* EqualTo */;
21673
+ }
21674
+ if (c1 === void 0) {
21645
21675
  return 1 /* GreaterThan */;
21646
21676
  }
21647
- const len = Math.min(t1.next.length, t2.next.length);
21648
- for (let i = 0; i < len; i++) {
21649
- res = compareMessageText(t1.next[i], t2.next[i]);
21677
+ if (c2 === void 0) {
21678
+ return -1 /* LessThan */;
21679
+ }
21680
+ let res = compareValues(c2.length, c1.length);
21681
+ if (res) {
21682
+ return res;
21683
+ }
21684
+ for (let i = 0; i < c2.length; i++) {
21685
+ res = compareMessageChainSize(c1[i].next, c2[i].next);
21650
21686
  if (res) {
21651
21687
  return res;
21652
21688
  }
21653
21689
  }
21654
- if (t1.next.length < t2.next.length) {
21655
- return -1 /* LessThan */;
21656
- } else if (t1.next.length > t2.next.length) {
21657
- return 1 /* GreaterThan */;
21690
+ return 0 /* EqualTo */;
21691
+ }
21692
+ function compareMessageChainContent(c1, c2) {
21693
+ let res;
21694
+ for (let i = 0; i < c2.length; i++) {
21695
+ res = compareStringsCaseSensitive(c1[i].messageText, c2[i].messageText);
21696
+ if (res) {
21697
+ return res;
21698
+ }
21699
+ if (c1[i].next === void 0) {
21700
+ continue;
21701
+ }
21702
+ res = compareMessageChainContent(c1[i].next, c2[i].next);
21703
+ if (res) {
21704
+ return res;
21705
+ }
21658
21706
  }
21659
21707
  return 0 /* EqualTo */;
21660
21708
  }
21709
+ function diagnosticsEqualityComparer(d1, d2) {
21710
+ return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) === 0 /* EqualTo */ && compareValues(d1.start, d2.start) === 0 /* EqualTo */ && compareValues(d1.length, d2.length) === 0 /* EqualTo */ && compareValues(d1.code, d2.code) === 0 /* EqualTo */ && messageTextEqualityComparer(d1.messageText, d2.messageText);
21711
+ }
21712
+ function messageTextEqualityComparer(m1, m2) {
21713
+ const t1 = typeof m1 === "string" ? m1 : m1.messageText;
21714
+ const t2 = typeof m2 === "string" ? m2 : m2.messageText;
21715
+ return compareStringsCaseSensitive(t1, t2) === 0 /* EqualTo */;
21716
+ }
21661
21717
  function getLanguageVariant(scriptKind) {
21662
21718
  return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
21663
21719
  }
@@ -22548,7 +22604,7 @@ function rangeOfTypeParameters(sourceFile, typeParameters) {
22548
22604
  return { pos, end };
22549
22605
  }
22550
22606
  function skipTypeChecking(sourceFile, options, host) {
22551
- return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib || host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
22607
+ return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib || options.noCheck || host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
22552
22608
  }
22553
22609
  function isJsonEqual(a, b) {
22554
22610
  return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a, b, isJsonEqual);
@@ -40474,6 +40530,20 @@ var commandOptionsWithoutBuild = [
40474
40530
  defaultValueDescription: false,
40475
40531
  description: Diagnostics.Disable_emitting_comments
40476
40532
  },
40533
+ {
40534
+ name: "noCheck",
40535
+ type: "boolean",
40536
+ showInSimplifiedHelpView: false,
40537
+ category: Diagnostics.Compiler_Diagnostics,
40538
+ description: Diagnostics.Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported,
40539
+ transpileOptionValue: void 0,
40540
+ defaultValueDescription: false,
40541
+ affectsSemanticDiagnostics: true,
40542
+ affectsBuildInfo: true,
40543
+ extraValidation() {
40544
+ return [Diagnostics.Unknown_compiler_option_0, "noCheck"];
40545
+ }
40546
+ },
40477
40547
  {
40478
40548
  name: "noEmit",
40479
40549
  type: "boolean",
@@ -42346,11 +42416,11 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
42346
42416
  const excludeOfRaw = getSpecsFromRaw("exclude");
42347
42417
  let isDefaultIncludeSpec = false;
42348
42418
  let excludeSpecs = toPropValue(excludeOfRaw);
42349
- if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
42350
- const outDir = raw.compilerOptions.outDir;
42351
- const declarationDir = raw.compilerOptions.declarationDir;
42419
+ if (excludeOfRaw === "no-prop") {
42420
+ const outDir = options.outDir;
42421
+ const declarationDir = options.declarationDir;
42352
42422
  if (outDir || declarationDir) {
42353
- excludeSpecs = [outDir, declarationDir].filter((d) => !!d);
42423
+ excludeSpecs = filter([outDir, declarationDir], (d) => !!d);
42354
42424
  }
42355
42425
  }
42356
42426
  if (filesSpecs === void 0 && includeSpecs === void 0) {
@@ -56910,6 +56980,7 @@ function createTypeChecker(host) {
56910
56980
  }
56911
56981
  }
56912
56982
  function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
56983
+ void getPropertiesOfType(getTypeOfSymbol(symbol));
56913
56984
  const visitedSym = getMergedSymbol(symbol);
56914
56985
  if (visitedSymbols.has(getSymbolId(visitedSym))) {
56915
56986
  return;
@@ -90156,6 +90227,7 @@ function createTypeChecker(host) {
90156
90227
  if (!sym) {
90157
90228
  return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker);
90158
90229
  }
90230
+ resolveExternalModuleSymbol(sym);
90159
90231
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
90160
90232
  },
90161
90233
  isImportRequiredByAugmentation
@@ -115477,12 +115549,13 @@ function createGetIsolatedDeclarationErrors(resolver) {
115477
115549
  // src/compiler/transformers/declarations.ts
115478
115550
  function getDeclarationDiagnostics(host, resolver, file) {
115479
115551
  const compilerOptions = host.getCompilerOptions();
115552
+ const files = filter(getSourceFilesToEmit(host, file), isSourceFileNotJson);
115480
115553
  const result = transformNodes(
115481
115554
  resolver,
115482
115555
  host,
115483
115556
  factory,
115484
115557
  compilerOptions,
115485
- file ? [file] : filter(host.getSourceFiles(), isSourceFileNotJson),
115558
+ file ? contains(files, file) ? [file] : emptyArray : files,
115486
115559
  [transformDeclarations],
115487
115560
  /*allowDtsFiles*/
115488
115561
  false
@@ -117920,7 +117993,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
117920
117993
  const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
117921
117994
  const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson);
117922
117995
  const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit;
117923
- if (emitOnly && !getEmitDeclarations(compilerOptions)) {
117996
+ if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck) {
117924
117997
  filesForEmit.forEach(collectLinkedAliases);
117925
117998
  }
117926
117999
  const declarationTransform = transformNodes(
@@ -126060,7 +126133,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
126060
126133
  continue;
126061
126134
  }
126062
126135
  const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
126063
- const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
126136
+ const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension) && !getProjectReferenceRedirectProject(resolution.resolvedFileName);
126064
126137
  const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
126065
126138
  const resolvedFileName = resolution.resolvedFileName;
126066
126139
  if (isFromNodeModulesSearch) {
@@ -126355,6 +126428,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
126355
126428
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
126356
126429
  }
126357
126430
  }
126431
+ if (options.noCheck) {
126432
+ if (options.noEmit) {
126433
+ createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noCheck", "noEmit");
126434
+ }
126435
+ if (!options.emitDeclarationOnly) {
126436
+ createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "noCheck", "emitDeclarationOnly");
126437
+ }
126438
+ }
126358
126439
  if (options.emitDecoratorMetadata && !options.experimentalDecorators) {
126359
126440
  createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
126360
126441
  }
@@ -137095,9 +137176,6 @@ function getModuleSpecifierResolverHost(program, host) {
137095
137176
  function moduleResolutionUsesNodeModules(moduleResolution) {
137096
137177
  return moduleResolution === 2 /* Node10 */ || moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
137097
137178
  }
137098
- function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) {
137099
- return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : void 0;
137100
- }
137101
137179
  function makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference, isTypeOnly) {
137102
137180
  return factory.createImportDeclaration(
137103
137181
  /*modifiers*/
@@ -137111,10 +137189,10 @@ function makeImport(defaultImport, namedImports, moduleSpecifier, quotePreferenc
137111
137189
  function makeStringLiteral(text, quotePreference) {
137112
137190
  return factory.createStringLiteral(text, quotePreference === 0 /* Single */);
137113
137191
  }
137114
- var QuotePreference = /* @__PURE__ */ ((QuotePreference7) => {
137115
- QuotePreference7[QuotePreference7["Single"] = 0] = "Single";
137116
- QuotePreference7[QuotePreference7["Double"] = 1] = "Double";
137117
- return QuotePreference7;
137192
+ var QuotePreference = /* @__PURE__ */ ((QuotePreference6) => {
137193
+ QuotePreference6[QuotePreference6["Single"] = 0] = "Single";
137194
+ QuotePreference6[QuotePreference6["Double"] = 1] = "Double";
137195
+ return QuotePreference6;
137118
137196
  })(QuotePreference || {});
137119
137197
  function quotePreferenceFromString(str, sourceFile) {
137120
137198
  return isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */;
@@ -141706,6 +141784,7 @@ function transpileWorker(input, transpileOptions, declaration) {
141706
141784
  options.declaration = true;
141707
141785
  options.emitDeclarationOnly = true;
141708
141786
  options.isolatedDeclarations = true;
141787
+ options.noCheck = true;
141709
141788
  } else {
141710
141789
  options.declaration = false;
141711
141790
  }
@@ -142697,16 +142776,16 @@ function cleanText(text) {
142697
142776
  var ts_refactor_exports = {};
142698
142777
  __export(ts_refactor_exports, {
142699
142778
  addExportToChanges: () => addExportToChanges,
142700
- addExports: () => addExports,
142779
+ addImportsForMovedSymbols: () => addImportsForMovedSymbols,
142701
142780
  addNewFileToTsconfig: () => addNewFileToTsconfig,
142702
142781
  addOrRemoveBracesToArrowFunction: () => ts_refactor_addOrRemoveBracesToArrowFunction_exports,
142782
+ addTargetFileImports: () => addTargetFileImports,
142703
142783
  containsJsx: () => containsJsx,
142704
142784
  convertArrowFunctionOrFunctionExpression: () => ts_refactor_convertArrowFunctionOrFunctionExpression_exports,
142705
142785
  convertParamsToDestructuredObject: () => ts_refactor_convertParamsToDestructuredObject_exports,
142706
142786
  convertStringOrTemplateLiteral: () => ts_refactor_convertStringOrTemplateLiteral_exports,
142707
142787
  convertToOptionalChainExpression: () => ts_refactor_convertToOptionalChainExpression_exports,
142708
142788
  createNewFileName: () => createNewFileName,
142709
- createOldFileImportsFromTargetFile: () => createOldFileImportsFromTargetFile,
142710
142789
  deleteMovedStatements: () => deleteMovedStatements,
142711
142790
  deleteUnusedImports: () => deleteUnusedImports,
142712
142791
  deleteUnusedOldImports: () => deleteUnusedOldImports,
@@ -142717,13 +142796,13 @@ __export(ts_refactor_exports, {
142717
142796
  generateGetAccessorAndSetAccessor: () => ts_refactor_generateGetAccessorAndSetAccessor_exports,
142718
142797
  getApplicableRefactors: () => getApplicableRefactors,
142719
142798
  getEditsForRefactor: () => getEditsForRefactor,
142799
+ getNewStatementsAndRemoveFromOldFile: () => getNewStatementsAndRemoveFromOldFile,
142720
142800
  getStatementsToMove: () => getStatementsToMove,
142721
142801
  getTopLevelDeclarationStatement: () => getTopLevelDeclarationStatement,
142722
142802
  getUsageInfo: () => getUsageInfo,
142723
142803
  inferFunctionReturnType: () => ts_refactor_inferFunctionReturnType_exports,
142724
142804
  isRefactorErrorInfo: () => isRefactorErrorInfo,
142725
142805
  isTopLevelDeclaration: () => isTopLevelDeclaration,
142726
- makeImportOrRequire: () => makeImportOrRequire,
142727
142806
  moduleSpecifierFromImport: () => moduleSpecifierFromImport,
142728
142807
  nameOfTopLevelDeclaration: () => nameOfTopLevelDeclaration,
142729
142808
  refactorKindBeginsWith: () => refactorKindBeginsWith,
@@ -143595,282 +143674,12 @@ function getExpandedSelectionNode(firstType, enclosingNode) {
143595
143674
  }) ?? firstType;
143596
143675
  }
143597
143676
 
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
143677
  // src/services/refactors/moveToFile.ts
143869
143678
  var refactorNameForMoveToFile = "Move to file";
143870
- var description2 = getLocaleSpecificMessage(Diagnostics.Move_to_file);
143679
+ var description = getLocaleSpecificMessage(Diagnostics.Move_to_file);
143871
143680
  var moveToFileAction = {
143872
143681
  name: "Move to file",
143873
- description: description2,
143682
+ description,
143874
143683
  kind: "refactor.move.file"
143875
143684
  };
143876
143685
  registerRefactor(refactorNameForMoveToFile, {
@@ -143893,10 +143702,10 @@ registerRefactor(refactorNameForMoveToFile, {
143893
143702
  start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
143894
143703
  end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
143895
143704
  };
143896
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
143705
+ return [{ name: refactorNameForMoveToFile, description, actions: [{ ...moveToFileAction, range: affectedTextRange }] }];
143897
143706
  }
143898
143707
  if (context.preferences.provideRefactorNotApplicableReason) {
143899
- return [{ name: refactorNameForMoveToFile, description: description2, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143708
+ return [{ name: refactorNameForMoveToFile, description, actions: [{ ...moveToFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
143900
143709
  }
143901
143710
  return emptyArray;
143902
143711
  },
@@ -143910,7 +143719,7 @@ registerRefactor(refactorNameForMoveToFile, {
143910
143719
  if (host.fileExists(targetFile) && program.getSourceFile(targetFile) === void 0) {
143911
143720
  return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_statements_to_the_selected_file));
143912
143721
  }
143913
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
143722
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
143914
143723
  return { edits, renameFilename: void 0, renameLocation: void 0 };
143915
143724
  }
143916
143725
  return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid));
@@ -143919,144 +143728,46 @@ registerRefactor(refactorNameForMoveToFile, {
143919
143728
  function error(notApplicableReason) {
143920
143729
  return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason };
143921
143730
  }
143922
- function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
143731
+ function doChange3(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
143923
143732
  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));
143733
+ const isForNewFile = !host.fileExists(targetFile);
143734
+ const targetSourceFile = isForNewFile ? createFutureSourceFile(targetFile, oldFile.externalModuleIndicator ? 99 /* ESNext */ : oldFile.commonJsModuleIndicator ? 1 /* CommonJS */ : void 0, program, host) : Debug.checkDefined(program.getSourceFile(targetFile));
143735
+ const importAdderForOldFile = ts_codefix_exports.createImportAdder(oldFile, context.program, context.preferences, context.host);
143736
+ const importAdderForNewFile = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host);
143737
+ getNewStatementsAndRemoveFromOldFile(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, isForNewFile ? void 0 : getExistingLocals(targetSourceFile, toMove.all, checker)), changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile);
143738
+ if (isForNewFile) {
143926
143739
  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
143740
  }
143932
143741
  }
143933
- function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) {
143742
+ function getNewStatementsAndRemoveFromOldFile(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile) {
143934
143743
  const checker = program.getTypeChecker();
143935
143744
  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);
143745
+ const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(targetFile.fileName, program, host, !!oldFile.commonJsModuleIndicator);
143942
143746
  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,
143747
+ addImportsForMovedSymbols(usage.oldFileImportsFromTargetFile, targetFile.fileName, importAdderForOldFile, program);
143748
+ deleteUnusedOldImports(oldFile, toMove.all, usage.unusedImportsFromOldFile, importAdderForOldFile);
143749
+ importAdderForOldFile.writeFixes(changes, quotePreference);
143750
+ deleteMovedStatements(oldFile, toMove.ranges, changes);
143751
+ updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, targetFile.fileName, quotePreference);
143752
+ addExportsInOldFile(oldFile, usage.targetFileImportsFromOldFile, changes, useEsModuleSyntax);
143753
+ addTargetFileImports(oldFile, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile, checker, program, importAdderForNewFile);
143754
+ if (!isFullSourceFile(targetFile) && prologueDirectives.length) {
143755
+ changes.insertStatementsInNewFile(targetFile.fileName, prologueDirectives, oldFile);
143756
+ }
143757
+ importAdderForNewFile.writeFixes(changes, quotePreference);
143758
+ const body = addExports(oldFile, toMove.all, arrayFrom(usage.oldFileImportsFromTargetFile.keys()), useEsModuleSyntax);
143759
+ if (isFullSourceFile(targetFile) && targetFile.statements.length > 0) {
143760
+ moveStatementsToTargetFile(changes, program, body, targetFile, toMove);
143761
+ } else if (isFullSourceFile(targetFile)) {
143762
+ changes.insertNodesAtEndOfFile(
143763
+ targetFile,
143764
+ body,
143949
143765
  /*blankLineBetween*/
143950
- true,
143951
- preferences
143766
+ false
143952
143767
  );
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
143768
  } 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
- }
143769
+ changes.insertStatementsInNewFile(targetFile.fileName, importAdderForNewFile.hasFixes() ? [4 /* NewLineTrivia */, ...body] : body, oldFile);
144029
143770
  }
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
143771
  }
144061
143772
  function addNewFileToTsconfig(program, changes, oldFileName, newFileNameWithExtension, getCanonicalFileName) {
144062
143773
  const cfg = program.getCompilerOptions().configFile;
@@ -144075,13 +143786,38 @@ function deleteMovedStatements(sourceFile, moved, changes) {
144075
143786
  changes.deleteNodeRangeExcludingEnd(sourceFile, first2, afterLast);
144076
143787
  }
144077
143788
  }
144078
- function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) {
143789
+ function deleteUnusedOldImports(oldFile, toMove, toDelete, importAdder) {
144079
143790
  for (const statement of oldFile.statements) {
144080
143791
  if (contains(toMove, statement))
144081
143792
  continue;
144082
- forEachImportInStatement(statement, (i) => deleteUnusedImports(oldFile, i, changes, (name) => toDelete.has(checker.getSymbolAtLocation(name))));
143793
+ forEachImportInStatement(statement, (i) => {
143794
+ forEachAliasDeclarationInImportOrRequire(i, (decl) => {
143795
+ if (toDelete.has(decl.symbol)) {
143796
+ importAdder.removeExistingImport(decl);
143797
+ }
143798
+ });
143799
+ });
144083
143800
  }
144084
143801
  }
143802
+ function addExportsInOldFile(oldFile, targetFileImportsFromOldFile, changes, useEsModuleSyntax) {
143803
+ const markSeenTop = nodeSeenTracker();
143804
+ targetFileImportsFromOldFile.forEach((_, symbol) => {
143805
+ if (!symbol.declarations) {
143806
+ return;
143807
+ }
143808
+ for (const decl of symbol.declarations) {
143809
+ if (!isTopLevelDeclaration(decl))
143810
+ continue;
143811
+ const name = nameOfTopLevelDeclaration(decl);
143812
+ if (!name)
143813
+ continue;
143814
+ const top = getTopLevelDeclarationStatement(decl);
143815
+ if (markSeenTop(top)) {
143816
+ addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
143817
+ }
143818
+ }
143819
+ });
143820
+ }
144085
143821
  function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols, targetFileName, quotePreference) {
144086
143822
  const checker = program.getTypeChecker();
144087
143823
  for (const sourceFile of program.getSourceFiles()) {
@@ -144220,45 +143956,39 @@ function forEachImportInStatement(statement, cb) {
144220
143956
  }
144221
143957
  }
144222
143958
  }
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);
143959
+ function forEachAliasDeclarationInImportOrRequire(importOrRequire, cb) {
143960
+ var _a, _b, _c, _d, _e;
143961
+ if (importOrRequire.kind === 272 /* ImportDeclaration */) {
143962
+ if ((_a = importOrRequire.importClause) == null ? void 0 : _a.name) {
143963
+ cb(importOrRequire.importClause);
144231
143964
  }
144232
- });
144233
- return makeImportOrRequire(sourceFile, defaultImport, imports, targetFileNameWithExtension, program, host, useEs6Imports, quotePreference);
143965
+ if (((_c = (_b = importOrRequire.importClause) == null ? void 0 : _b.namedBindings) == null ? void 0 : _c.kind) === 274 /* NamespaceImport */) {
143966
+ cb(importOrRequire.importClause.namedBindings);
143967
+ }
143968
+ if (((_e = (_d = importOrRequire.importClause) == null ? void 0 : _d.namedBindings) == null ? void 0 : _e.kind) === 275 /* NamedImports */) {
143969
+ for (const element of importOrRequire.importClause.namedBindings.elements) {
143970
+ cb(element);
143971
+ }
143972
+ }
143973
+ } else if (importOrRequire.kind === 271 /* ImportEqualsDeclaration */) {
143974
+ cb(importOrRequire);
143975
+ } else if (importOrRequire.kind === 260 /* VariableDeclaration */) {
143976
+ if (importOrRequire.name.kind === 80 /* Identifier */) {
143977
+ cb(importOrRequire);
143978
+ } else if (importOrRequire.name.kind === 206 /* ObjectBindingPattern */) {
143979
+ for (const element of importOrRequire.name.elements) {
143980
+ if (isIdentifier(element.name)) {
143981
+ cb(element);
143982
+ }
143983
+ }
143984
+ }
143985
+ }
144234
143986
  }
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;
143987
+ function addImportsForMovedSymbols(symbols, targetFileName, importAdder, program) {
143988
+ for (const [symbol, isValidTypeOnlyUseSite] of symbols) {
143989
+ const symbolName2 = getNameForExportedSymbol(symbol, getEmitScriptTarget(program.getCompilerOptions()));
143990
+ const exportKind = symbol.name === "default" && symbol.parent ? 1 /* Default */ : 0 /* Named */;
143991
+ importAdder.addImportForNonExistentExport(symbolName2, targetFileName, exportKind, symbol.flags, isValidTypeOnlyUseSite);
144262
143992
  }
144263
143993
  }
144264
143994
  function makeVariableStatement(name, type, initializer, flags = 2 /* Const */) {
@@ -144278,7 +144008,7 @@ function addExports(sourceFile, toMove, needExport, useEs6Exports) {
144278
144008
  return flatMap(toMove, (statement) => {
144279
144009
  if (isTopLevelDeclarationStatement(statement) && !isExported(sourceFile, statement, useEs6Exports) && forEachTopLevelDeclaration(statement, (d) => {
144280
144010
  var _a;
144281
- return needExport.has(Debug.checkDefined((_a = tryCast(d, canHaveSymbol)) == null ? void 0 : _a.symbol));
144011
+ return needExport.includes(Debug.checkDefined((_a = tryCast(d, canHaveSymbol)) == null ? void 0 : _a.symbol));
144282
144012
  })) {
144283
144013
  const exports2 = addExport(getSynthesizedDeepClone(statement), useEs6Exports);
144284
144014
  if (exports2)
@@ -144295,86 +144025,17 @@ function isExported(sourceFile, decl, useEs6Exports, name) {
144295
144025
  return !!sourceFile.symbol && !!sourceFile.symbol.exports && getNamesToExportInCommonJS(decl).some((name2) => sourceFile.symbol.exports.has(escapeLeadingUnderscores(name2)));
144296
144026
  }
144297
144027
  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);
144028
+ if (importDecl.kind === 272 /* ImportDeclaration */ && importDecl.importClause) {
144029
+ const { name, namedBindings } = importDecl.importClause;
144030
+ if ((!name || isUnused(name)) && (!namedBindings || namedBindings.kind === 275 /* NamedImports */ && namedBindings.elements.length !== 0 && namedBindings.elements.every((e) => isUnused(e.name)))) {
144031
+ return changes.delete(sourceFile, importDecl);
144325
144032
  }
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
144033
  }
144034
+ forEachAliasDeclarationInImportOrRequire(importDecl, (i) => {
144035
+ if (i.name && isIdentifier(i.name) && isUnused(i.name)) {
144036
+ changes.delete(sourceFile, i);
144037
+ }
144038
+ });
144378
144039
  }
144379
144040
  function isTopLevelDeclarationStatement(node) {
144380
144041
  Debug.assert(isSourceFile(node.parent), "Node parent should be a SourceFile");
@@ -144598,12 +144259,13 @@ function isPureImport(node) {
144598
144259
  }
144599
144260
  }
144600
144261
  function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PURE__ */ new Set()) {
144262
+ var _a;
144601
144263
  const movedSymbols = /* @__PURE__ */ new Set();
144602
144264
  const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map();
144603
- const targetFileImportsFromOldFile = /* @__PURE__ */ new Set();
144265
+ const targetFileImportsFromOldFile = /* @__PURE__ */ new Map();
144604
144266
  const jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx(toMove));
144605
144267
  if (jsxNamespaceSymbol) {
144606
- oldImportsNeededByTargetFile.set(jsxNamespaceSymbol, false);
144268
+ 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
144269
  }
144608
144270
  for (const statement of toMove) {
144609
144271
  forEachTopLevelDeclaration(statement, (decl) => {
@@ -144623,9 +144285,12 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
144623
144285
  for (const decl of symbol.declarations) {
144624
144286
  if (isInImport(decl)) {
144625
144287
  const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol);
144626
- oldImportsNeededByTargetFile.set(symbol, prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite);
144288
+ oldImportsNeededByTargetFile.set(symbol, [
144289
+ prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite,
144290
+ tryCast(decl, (d) => isImportSpecifier(d) || isImportClause(d) || isNamespaceImport(d) || isImportEqualsDeclaration(d) || isBindingElement(d) || isVariableDeclaration(d))
144291
+ ]);
144627
144292
  } else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) {
144628
- targetFileImportsFromOldFile.add(symbol);
144293
+ targetFileImportsFromOldFile.set(symbol, isValidTypeOnlyUseSite);
144629
144294
  }
144630
144295
  }
144631
144296
  });
@@ -144633,16 +144298,16 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
144633
144298
  for (const unusedImport of oldImportsNeededByTargetFile.keys()) {
144634
144299
  unusedImportsFromOldFile.add(unusedImport);
144635
144300
  }
144636
- const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set();
144301
+ const oldFileImportsFromTargetFile = /* @__PURE__ */ new Map();
144637
144302
  for (const statement of oldFile.statements) {
144638
144303
  if (contains(toMove, statement))
144639
144304
  continue;
144640
144305
  if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) {
144641
144306
  unusedImportsFromOldFile.delete(jsxNamespaceSymbol);
144642
144307
  }
144643
- forEachReference(statement, checker, (symbol) => {
144308
+ forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
144644
144309
  if (movedSymbols.has(symbol))
144645
- oldFileImportsFromTargetFile.add(symbol);
144310
+ oldFileImportsFromTargetFile.set(symbol, isValidTypeOnlyUseSite);
144646
144311
  unusedImportsFromOldFile.delete(symbol);
144647
144312
  });
144648
144313
  }
@@ -144850,6 +144515,218 @@ function getExistingLocals(sourceFile, statements, checker) {
144850
144515
  return existingLocals;
144851
144516
  }
144852
144517
 
144518
+ // src/services/refactors/helpers.ts
144519
+ function isRefactorErrorInfo(info) {
144520
+ return info.error !== void 0;
144521
+ }
144522
+ function refactorKindBeginsWith(known, requested) {
144523
+ if (!requested)
144524
+ return true;
144525
+ return known.substr(0, requested.length) === requested;
144526
+ }
144527
+ function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFile, checker, program, importAdder) {
144528
+ importsToCopy.forEach(([isValidTypeOnlyUseSite, declaration], symbol) => {
144529
+ var _a;
144530
+ const targetSymbol = skipAlias(symbol, checker);
144531
+ if (checker.isUnknownSymbol(targetSymbol)) {
144532
+ importAdder.addVerbatimImport(Debug.checkDefined(declaration ?? findAncestor((_a = symbol.declarations) == null ? void 0 : _a[0], isAnyImportOrRequireStatement)));
144533
+ } else {
144534
+ importAdder.addImportFromExportedSymbol(targetSymbol, isValidTypeOnlyUseSite, declaration);
144535
+ }
144536
+ });
144537
+ addImportsForMovedSymbols(targetFileImportsFromOldFile, oldFile.fileName, importAdder, program);
144538
+ }
144539
+
144540
+ // src/services/refactors/inlineVariable.ts
144541
+ var refactorName4 = "Inline variable";
144542
+ var refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
144543
+ var inlineVariableAction = {
144544
+ name: refactorName4,
144545
+ description: refactorDescription,
144546
+ kind: "refactor.inline.variable"
144547
+ };
144548
+ registerRefactor(refactorName4, {
144549
+ kinds: [inlineVariableAction.kind],
144550
+ getAvailableActions(context) {
144551
+ const {
144552
+ file,
144553
+ program,
144554
+ preferences,
144555
+ startPosition,
144556
+ triggerReason
144557
+ } = context;
144558
+ const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
144559
+ if (!info) {
144560
+ return emptyArray;
144561
+ }
144562
+ if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
144563
+ return [{
144564
+ name: refactorName4,
144565
+ description: refactorDescription,
144566
+ actions: [inlineVariableAction]
144567
+ }];
144568
+ }
144569
+ if (preferences.provideRefactorNotApplicableReason) {
144570
+ return [{
144571
+ name: refactorName4,
144572
+ description: refactorDescription,
144573
+ actions: [{
144574
+ ...inlineVariableAction,
144575
+ notApplicableReason: info.error
144576
+ }]
144577
+ }];
144578
+ }
144579
+ return emptyArray;
144580
+ },
144581
+ getEditsForAction(context, actionName2) {
144582
+ Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
144583
+ const { file, program, startPosition } = context;
144584
+ const info = getInliningInfo(
144585
+ file,
144586
+ startPosition,
144587
+ /*tryWithReferenceToken*/
144588
+ true,
144589
+ program
144590
+ );
144591
+ if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
144592
+ return void 0;
144593
+ }
144594
+ const { references, declaration, replacement } = info;
144595
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
144596
+ for (const node of references) {
144597
+ tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
144598
+ }
144599
+ tracker.delete(file, declaration);
144600
+ });
144601
+ return { edits };
144602
+ }
144603
+ });
144604
+ function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
144605
+ var _a, _b;
144606
+ const checker = program.getTypeChecker();
144607
+ const token = getTouchingPropertyName(file, startPosition);
144608
+ const parent2 = token.parent;
144609
+ if (!isIdentifier(token)) {
144610
+ return void 0;
144611
+ }
144612
+ if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
144613
+ if (((_a = checker.getMergedSymbol(parent2.symbol).declarations) == null ? void 0 : _a.length) !== 1) {
144614
+ return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
144615
+ }
144616
+ if (isDeclarationExported(parent2)) {
144617
+ return void 0;
144618
+ }
144619
+ const references = getReferenceNodes(parent2, checker, file);
144620
+ return references && { references, declaration: parent2, replacement: parent2.initializer };
144621
+ }
144622
+ if (tryWithReferenceToken) {
144623
+ let definition = checker.resolveName(
144624
+ token.text,
144625
+ token,
144626
+ 111551 /* Value */,
144627
+ /*excludeGlobals*/
144628
+ false
144629
+ );
144630
+ definition = definition && checker.getMergedSymbol(definition);
144631
+ if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
144632
+ return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
144633
+ }
144634
+ const declaration = definition.declarations[0];
144635
+ if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
144636
+ return void 0;
144637
+ }
144638
+ if (isDeclarationExported(declaration)) {
144639
+ return void 0;
144640
+ }
144641
+ const references = getReferenceNodes(declaration, checker, file);
144642
+ return references && { references, declaration, replacement: declaration.initializer };
144643
+ }
144644
+ return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
144645
+ }
144646
+ function isDeclarationExported(declaration) {
144647
+ const variableStatement = cast(declaration.parent.parent, isVariableStatement);
144648
+ return some(variableStatement.modifiers, isExportModifier);
144649
+ }
144650
+ function getReferenceNodes(declaration, checker, file) {
144651
+ const references = [];
144652
+ const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
144653
+ if (ts_FindAllReferences_exports.isWriteAccessForReference(ref) && !isShorthandPropertyAssignment(ref.parent)) {
144654
+ return true;
144655
+ }
144656
+ if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
144657
+ return true;
144658
+ }
144659
+ if (isTypeQueryNode(ref.parent)) {
144660
+ return true;
144661
+ }
144662
+ if (textRangeContainsPositionInclusive(declaration, ref.pos)) {
144663
+ return true;
144664
+ }
144665
+ references.push(ref);
144666
+ });
144667
+ return references.length === 0 || cannotInline ? void 0 : references;
144668
+ }
144669
+ function getReplacementExpression(reference, replacement) {
144670
+ replacement = getSynthesizedDeepClone(replacement);
144671
+ const { parent: parent2 } = reference;
144672
+ if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
144673
+ return factory.createParenthesizedExpression(replacement);
144674
+ }
144675
+ if (isFunctionLike(replacement) && (isCallLikeExpression(parent2) || isPropertyAccessExpression(parent2))) {
144676
+ return factory.createParenthesizedExpression(replacement);
144677
+ }
144678
+ if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
144679
+ return factory.createParenthesizedExpression(replacement);
144680
+ }
144681
+ if (isIdentifier(reference) && isShorthandPropertyAssignment(parent2)) {
144682
+ return factory.createPropertyAssignment(reference, replacement);
144683
+ }
144684
+ return replacement;
144685
+ }
144686
+
144687
+ // src/services/refactors/moveToNewFile.ts
144688
+ var refactorName5 = "Move to a new file";
144689
+ var description2 = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
144690
+ var moveToNewFileAction = {
144691
+ name: refactorName5,
144692
+ description: description2,
144693
+ kind: "refactor.move.newFile"
144694
+ };
144695
+ registerRefactor(refactorName5, {
144696
+ kinds: [moveToNewFileAction.kind],
144697
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
144698
+ const statements = getStatementsToMove(context);
144699
+ if (context.preferences.allowTextChangesInNewFiles && statements) {
144700
+ const file = context.file;
144701
+ const affectedTextRange = {
144702
+ start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
144703
+ end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
144704
+ };
144705
+ return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
144706
+ }
144707
+ if (context.preferences.provideRefactorNotApplicableReason) {
144708
+ return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }] }];
144709
+ }
144710
+ return emptyArray;
144711
+ },
144712
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
144713
+ Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
144714
+ const statements = Debug.checkDefined(getStatementsToMove(context));
144715
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context.file, context.program, statements, t, context.host, context, context.preferences));
144716
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
144717
+ }
144718
+ });
144719
+ function doChange4(oldFile, program, toMove, changes, host, context, preferences) {
144720
+ const checker = program.getTypeChecker();
144721
+ const usage = getUsageInfo(oldFile, toMove.all, checker);
144722
+ const newFilename = createNewFileName(oldFile, program, host, toMove);
144723
+ const newSourceFile = createFutureSourceFile(newFilename, oldFile.externalModuleIndicator ? 99 /* ESNext */ : oldFile.commonJsModuleIndicator ? 1 /* CommonJS */ : void 0, program, host);
144724
+ const importAdderForOldFile = ts_codefix_exports.createImportAdder(oldFile, context.program, context.preferences, context.host);
144725
+ const importAdderForNewFile = ts_codefix_exports.createImportAdder(newSourceFile, context.program, context.preferences, context.host);
144726
+ getNewStatementsAndRemoveFromOldFile(oldFile, newSourceFile, usage, changes, toMove, program, host, preferences, importAdderForNewFile, importAdderForOldFile);
144727
+ addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
144728
+ }
144729
+
144853
144730
  // src/services/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts
144854
144731
  var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {};
144855
144732
 
@@ -154841,6 +154718,14 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
154841
154718
  entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly));
154842
154719
  break;
154843
154720
  case 3 /* CommonJS */:
154721
+ if (compilerOptions.verbatimModuleSyntax) {
154722
+ const prevValue2 = (entry.namedImports || (entry.namedImports = /* @__PURE__ */ new Map())).get(symbolName2);
154723
+ entry.namedImports.set(symbolName2, reduceAddAsTypeOnlyValues(prevValue2, addAsTypeOnly));
154724
+ } else {
154725
+ Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
154726
+ entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
154727
+ }
154728
+ break;
154844
154729
  case 2 /* Namespace */:
154845
154730
  Debug.assert(entry.namespaceLikeImport === void 0 || entry.namespaceLikeImport.name === symbolName2, "Namespacelike import shoudl be missing or match symbolName");
154846
154731
  entry.namespaceLikeImport = { importKind, name: symbolName2, addAsTypeOnly };
@@ -162853,6 +162738,8 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
162853
162738
  entries,
162854
162739
  keywordEntry,
162855
162740
  compareCompletionEntries,
162741
+ /*equalityComparer*/
162742
+ void 0,
162856
162743
  /*allowDuplicates*/
162857
162744
  true
162858
162745
  );
@@ -162866,6 +162753,8 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
162866
162753
  entries,
162867
162754
  keywordEntry,
162868
162755
  compareCompletionEntries,
162756
+ /*equalityComparer*/
162757
+ void 0,
162869
162758
  /*allowDuplicates*/
162870
162759
  true
162871
162760
  );
@@ -162878,6 +162767,8 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
162878
162767
  entries,
162879
162768
  literalEntry,
162880
162769
  compareCompletionEntries,
162770
+ /*equalityComparer*/
162771
+ void 0,
162881
162772
  /*allowDuplicates*/
162882
162773
  true
162883
162774
  );
@@ -163800,6 +163691,8 @@ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, con
163800
163691
  entries,
163801
163692
  entry,
163802
163693
  compareCompletionEntries,
163694
+ /*equalityComparer*/
163695
+ void 0,
163803
163696
  /*allowDuplicates*/
163804
163697
  true
163805
163698
  );
@@ -178397,6 +178290,7 @@ __export(ts_exports2, {
178397
178290
  defaultMaximumTruncationLength: () => defaultMaximumTruncationLength,
178398
178291
  diagnosticCategoryName: () => diagnosticCategoryName,
178399
178292
  diagnosticToString: () => diagnosticToString,
178293
+ diagnosticsEqualityComparer: () => diagnosticsEqualityComparer,
178400
178294
  directoryProbablyExists: () => directoryProbablyExists,
178401
178295
  directorySeparator: () => directorySeparator,
178402
178296
  displayPart: () => displayPart,
@@ -179780,7 +179674,6 @@ __export(ts_exports2, {
179780
179674
  loadWithModeAwareCache: () => loadWithModeAwareCache,
179781
179675
  makeIdentifierFromModuleName: () => makeIdentifierFromModuleName,
179782
179676
  makeImport: () => makeImport,
179783
- makeImportIfNecessary: () => makeImportIfNecessary,
179784
179677
  makeStringLiteral: () => makeStringLiteral,
179785
179678
  mangleScopedPackageName: () => mangleScopedPackageName,
179786
179679
  map: () => map,
@@ -192824,6 +192717,7 @@ if (typeof console !== "undefined") {
192824
192717
  defaultMaximumTruncationLength,
192825
192718
  diagnosticCategoryName,
192826
192719
  diagnosticToString,
192720
+ diagnosticsEqualityComparer,
192827
192721
  directoryProbablyExists,
192828
192722
  directorySeparator,
192829
192723
  displayPart,
@@ -194207,7 +194101,6 @@ if (typeof console !== "undefined") {
194207
194101
  loadWithModeAwareCache,
194208
194102
  makeIdentifierFromModuleName,
194209
194103
  makeImport,
194210
- makeImportIfNecessary,
194211
194104
  makeStringLiteral,
194212
194105
  mangleScopedPackageName,
194213
194106
  map,