typescript 4.8.0-dev.20220707 → 4.8.0-dev.20220710

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/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220707";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220710";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -2065,7 +2065,7 @@ var ts;
2065
2065
  * and 1 insertion/deletion at 3 characters)
2066
2066
  */
2067
2067
  function getSpellingSuggestion(name, candidates, getName) {
2068
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2068
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
2069
2069
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2070
2070
  var bestCandidate;
2071
2071
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -9049,6 +9049,7 @@ var ts;
9049
9049
  The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9050
9050
  _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
9051
9051
  We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
9052
+ Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
9052
9053
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
9053
9054
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
9054
9055
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -44428,6 +44429,7 @@ var ts;
44428
44429
  return toSearchResult(/*value*/ undefined);
44429
44430
  }
44430
44431
  /**
44432
+ * @internal
44431
44433
  * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44432
44434
  * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44433
44435
  */
@@ -44450,6 +44452,7 @@ var ts;
44450
44452
  return 1;
44451
44453
  return 0;
44452
44454
  }
44455
+ ts.comparePatternKeys = comparePatternKeys;
44453
44456
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44454
44457
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44455
44458
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -50256,6 +50259,7 @@ var ts;
50256
50259
  if (ctor && ctor.locals) {
50257
50260
  if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
50258
50261
  // Remember the property node, it will be used later to report appropriate error
50262
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
50259
50263
  propertyWithInvalidInitializer = location;
50260
50264
  }
50261
50265
  }
@@ -50445,11 +50449,27 @@ var ts;
50445
50449
  }
50446
50450
  }
50447
50451
  }
50452
+ // The invalid initializer error is needed in two situation:
50453
+ // 1. When result is undefined, after checking for a missing "this."
50454
+ // 2. When result is defined
50455
+ function checkAndReportErrorForInvalidInitializer() {
50456
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50457
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
50458
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50459
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
50460
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
50461
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
50462
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
50463
+ return true;
50464
+ }
50465
+ return false;
50466
+ }
50448
50467
  if (!result) {
50449
50468
  if (nameNotFoundMessage) {
50450
50469
  addLazyDiagnostic(function () {
50451
50470
  if (!errorLocation ||
50452
50471
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
50472
+ !checkAndReportErrorForInvalidInitializer() &&
50453
50473
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50454
50474
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50455
50475
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -50457,7 +50477,16 @@ var ts;
50457
50477
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50458
50478
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50459
50479
  var suggestion = void 0;
50460
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50480
+ var suggestedLib = void 0;
50481
+ // Report missing lib first
50482
+ if (nameArg) {
50483
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
50484
+ if (suggestedLib) {
50485
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
50486
+ }
50487
+ }
50488
+ // then spelling suggestions
50489
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50461
50490
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
50462
50491
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
50463
50492
  if (isGlobalScopeAugmentationDeclaration) {
@@ -50476,16 +50505,9 @@ var ts;
50476
50505
  }
50477
50506
  }
50478
50507
  }
50479
- if (!suggestion) {
50480
- if (nameArg) {
50481
- var lib = getSuggestedLibForNonExistentName(nameArg);
50482
- if (lib) {
50483
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
50484
- }
50485
- else {
50486
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50487
- }
50488
- }
50508
+ // And then fall back to unspecified "not found"
50509
+ if (!suggestion && !suggestedLib && nameArg) {
50510
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50489
50511
  }
50490
50512
  suggestionCount++;
50491
50513
  }
@@ -50493,12 +50515,7 @@ var ts;
50493
50515
  }
50494
50516
  return undefined;
50495
50517
  }
50496
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50497
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
50498
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50499
- // with ESNext+useDefineForClassFields because the scope semantics are different.
50500
- var propertyName = propertyWithInvalidInitializer.name;
50501
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
50518
+ else if (checkAndReportErrorForInvalidInitializer()) {
50502
50519
  return undefined;
50503
50520
  }
50504
50521
  // Perform extra checks only if error reporting was requested
@@ -62365,19 +62382,22 @@ var ts;
62365
62382
  * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
62366
62383
  */
62367
62384
  function isPossiblyReducibleByInstantiation(type) {
62368
- return ts.some(type.types, function (t) {
62369
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
62370
- return getReducedType(uniqueFilled) !== uniqueFilled;
62371
- });
62385
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
62386
+ return getReducedType(uniqueFilled) !== uniqueFilled;
62387
+ }
62388
+ function shouldDeferIndexType(type) {
62389
+ return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
62390
+ isGenericTupleType(type) ||
62391
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
62392
+ type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
62393
+ type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
62372
62394
  }
62373
62395
  function getIndexType(type, stringsOnly, noIndexSignatures) {
62374
62396
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
62375
62397
  type = getReducedType(type);
62376
- return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
62377
- ? getIndexTypeForGenericType(type, stringsOnly)
62378
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62379
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62380
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62398
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62399
+ type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62400
+ type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62381
62401
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
62382
62402
  type === wildcardType ? wildcardType :
62383
62403
  type.flags & 2 /* Unknown */ ? neverType :
@@ -69967,6 +69987,15 @@ var ts;
69967
69987
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
69968
69988
  return key && key + "." + propName;
69969
69989
  }
69990
+ break;
69991
+ case 201 /* ObjectBindingPattern */:
69992
+ case 202 /* ArrayBindingPattern */:
69993
+ case 256 /* FunctionDeclaration */:
69994
+ case 213 /* FunctionExpression */:
69995
+ case 214 /* ArrowFunction */:
69996
+ case 169 /* MethodDeclaration */:
69997
+ // Handle pseudo-references originating in getNarrowedTypeOfSymbol.
69998
+ return getNodeId(node) + "#" + getTypeId(declaredType);
69970
69999
  }
69971
70000
  return undefined;
69972
70001
  }
@@ -132380,6 +132409,26 @@ var ts;
132380
132409
  (function (Completions) {
132381
132410
  var StringCompletions;
132382
132411
  (function (StringCompletions) {
132412
+ var _a;
132413
+ var kindPrecedence = (_a = {},
132414
+ _a["directory" /* directory */] = 0,
132415
+ _a["script" /* scriptElement */] = 1,
132416
+ _a["external module name" /* externalModuleName */] = 2,
132417
+ _a);
132418
+ function createNameAndKindSet() {
132419
+ var map = new ts.Map();
132420
+ function add(value) {
132421
+ var existing = map.get(value.name);
132422
+ if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
132423
+ map.set(value.name, value);
132424
+ }
132425
+ }
132426
+ return {
132427
+ add: add,
132428
+ has: map.has.bind(map),
132429
+ values: map.values.bind(map),
132430
+ };
132431
+ }
132383
132432
  function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
132384
132433
  if (ts.isInReferenceComment(sourceFile, position)) {
132385
132434
  var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
@@ -132661,11 +132710,12 @@ var ts;
132661
132710
  }
132662
132711
  function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
132663
132712
  var literalValue = ts.normalizeSlashes(node.text);
132713
+ var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
132664
132714
  var scriptPath = sourceFile.path;
132665
132715
  var scriptDirectory = ts.getDirectoryPath(scriptPath);
132666
132716
  return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
132667
132717
  ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
132668
- : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
132718
+ : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
132669
132719
  function getIncludeExtensionOption() {
132670
132720
  var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
132671
132721
  return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
@@ -132681,7 +132731,7 @@ var ts;
132681
132731
  return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
132682
132732
  }
132683
132733
  else {
132684
- return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
132734
+ return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
132685
132735
  }
132686
132736
  }
132687
132737
  function isEmitResolutionKindUsingNodeModules(compilerOptions) {
@@ -132717,7 +132767,7 @@ var ts;
132717
132767
  var basePath = compilerOptions.project || host.getCurrentDirectory();
132718
132768
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
132719
132769
  var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
132720
- return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); });
132770
+ return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); });
132721
132771
  }
132722
132772
  var IncludeExtensionsOption;
132723
132773
  (function (IncludeExtensionsOption) {
@@ -132728,10 +132778,9 @@ var ts;
132728
132778
  /**
132729
132779
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
132730
132780
  */
132731
- function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
132732
- var _b;
132733
- var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
132734
- if (result === void 0) { result = []; }
132781
+ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
132782
+ var _a;
132783
+ if (result === void 0) { result = createNameAndKindSet(); }
132735
132784
  if (fragment === undefined) {
132736
132785
  fragment = "";
132737
132786
  }
@@ -132755,11 +132804,11 @@ var ts;
132755
132804
  var packageJson = ts.readJson(packageJsonPath, host);
132756
132805
  var typesVersions = packageJson.typesVersions;
132757
132806
  if (typeof typesVersions === "object") {
132758
- var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
132807
+ var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
132759
132808
  if (versionPaths) {
132760
132809
  var packageDirectory = ts.getDirectoryPath(packageJsonPath);
132761
132810
  var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
132762
- if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
132811
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
132763
132812
  // A true result means one of the `versionPaths` was matched, which will block relative resolution
132764
132813
  // to files and folders from here. All reachable paths given the pattern match are already added.
132765
132814
  return result;
@@ -132771,39 +132820,17 @@ var ts;
132771
132820
  if (!ts.tryDirectoryExists(host, baseDirectory))
132772
132821
  return result;
132773
132822
  // Enumerate the available files if possible
132774
- var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
132823
+ var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
132775
132824
  if (files) {
132776
- /**
132777
- * Multiple file entries might map to the same truncated name once we remove extensions
132778
- * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
132779
- *
132780
- * both foo.ts and foo.tsx become foo
132781
- */
132782
- var foundFiles = new ts.Map(); // maps file to its extension
132783
132825
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
132784
132826
  var filePath = files_1[_i];
132785
132827
  filePath = ts.normalizePath(filePath);
132786
132828
  if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
132787
132829
  continue;
132788
132830
  }
132789
- var foundFileName = void 0;
132790
- var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
132791
- if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
132792
- foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
132793
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
132794
- }
132795
- else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
132796
- foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
132797
- foundFiles.set(foundFileName, outputExtension);
132798
- }
132799
- else {
132800
- foundFileName = ts.getBaseFileName(filePath);
132801
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
132802
- }
132831
+ var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension;
132832
+ result.add(nameAndKind(name, "script" /* scriptElement */, extension));
132803
132833
  }
132804
- foundFiles.forEach(function (ext, foundFile) {
132805
- result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
132806
- });
132807
132834
  }
132808
132835
  // If possible, get folder completion as well
132809
132836
  var directories = ts.tryGetDirectories(host, baseDirectory);
@@ -132812,27 +132839,52 @@ var ts;
132812
132839
  var directory = directories_1[_c];
132813
132840
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
132814
132841
  if (directoryName !== "@types") {
132815
- result.push(directoryResult(directoryName));
132842
+ result.add(directoryResult(directoryName));
132816
132843
  }
132817
132844
  }
132818
132845
  }
132819
132846
  return result;
132820
132847
  }
132848
+ function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) {
132849
+ var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
132850
+ if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
132851
+ return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) };
132852
+ }
132853
+ else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
132854
+ return { name: ts.changeExtension(name, outputExtension), extension: outputExtension };
132855
+ }
132856
+ else {
132857
+ return { name: name, extension: ts.tryGetExtensionFromPath(name) };
132858
+ }
132859
+ }
132821
132860
  /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
132822
- function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
132823
- var _a;
132861
+ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
132862
+ var getPatternsForKey = function (key) { return paths[key]; };
132863
+ var comparePaths = function (a, b) {
132864
+ var patternA = ts.tryParsePattern(a);
132865
+ var patternB = ts.tryParsePattern(b);
132866
+ var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
132867
+ var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
132868
+ return ts.compareValues(lengthB, lengthA);
132869
+ };
132870
+ return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths);
132871
+ }
132872
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
132873
+ function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) {
132824
132874
  var pathResults = [];
132825
- var matchedPathPrefixLength = -1;
132826
- for (var path in paths) {
132827
- if (!ts.hasProperty(paths, path))
132875
+ var matchedPath;
132876
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
132877
+ var key = keys_1[_i];
132878
+ if (key === ".")
132828
132879
  continue;
132829
- var patterns = paths[path];
132880
+ var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
132881
+ var patterns = getPatternsForKey(key);
132830
132882
  if (patterns) {
132831
- var pathPattern = ts.tryParsePattern(path);
132883
+ var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
132832
132884
  if (!pathPattern)
132833
132885
  continue;
132834
132886
  var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
132835
- var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
132887
+ var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
132836
132888
  if (isLongestMatch) {
132837
132889
  // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
132838
132890
  // for `import {} from "some-package/|"` with a typesVersions:
@@ -132845,13 +132897,13 @@ var ts;
132845
132897
  // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
132846
132898
  // ./dist/foo and ./foo, when only the latter will actually be resolvable.
132847
132899
  // See pathCompletionsTypesVersionsWildcard6.ts.
132848
- matchedPathPrefixLength = pathPattern.prefix.length;
132900
+ matchedPath = key;
132849
132901
  pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
132850
132902
  }
132851
- if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
132903
+ if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
132852
132904
  pathResults.push({
132853
132905
  matchedPattern: isMatch,
132854
- results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
132906
+ results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
132855
132907
  .map(function (_a) {
132856
132908
  var name = _a.name, kind = _a.kind, extension = _a.extension;
132857
132909
  return nameAndKind(name, kind, extension);
@@ -132860,10 +132912,8 @@ var ts;
132860
132912
  }
132861
132913
  }
132862
132914
  }
132863
- var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
132864
- var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
132865
- pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
132866
- return matchedPathPrefixLength > -1;
132915
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
132916
+ return matchedPath !== undefined;
132867
132917
  }
132868
132918
  /**
132869
132919
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -132872,22 +132922,22 @@ var ts;
132872
132922
  * Modules from node_modules (i.e. those listed in package.json)
132873
132923
  * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
132874
132924
  */
132875
- function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
132925
+ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
132876
132926
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
132877
- var result = [];
132878
- var extensionOptions = getExtensionOptions(compilerOptions);
132927
+ var result = createNameAndKindSet();
132928
+ var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
132879
132929
  if (baseUrl) {
132880
132930
  var projectDir = compilerOptions.project || host.getCurrentDirectory();
132881
132931
  var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
132882
132932
  getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
132883
132933
  if (paths) {
132884
- addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host);
132934
+ addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
132885
132935
  }
132886
132936
  }
132887
132937
  var fragmentDirectory = getFragmentDirectory(fragment);
132888
132938
  for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
132889
132939
  var ambientName = _a[_i];
132890
- result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
132940
+ result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
132891
132941
  }
132892
132942
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
132893
132943
  if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
@@ -132895,15 +132945,13 @@ var ts;
132895
132945
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
132896
132946
  var foundGlobal = false;
132897
132947
  if (fragmentDirectory === undefined) {
132898
- var _loop_3 = function (moduleName) {
132899
- if (!result.some(function (entry) { return entry.name === moduleName; })) {
132900
- foundGlobal = true;
132901
- result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
132902
- }
132903
- };
132904
132948
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
132905
132949
  var moduleName = _c[_b];
132906
- _loop_3(moduleName);
132950
+ var moduleResult = nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined);
132951
+ if (!result.has(moduleResult.name)) {
132952
+ foundGlobal = true;
132953
+ result.add(moduleResult);
132954
+ }
132907
132955
  }
132908
132956
  }
132909
132957
  if (!foundGlobal) {
@@ -132929,39 +132977,19 @@ var ts;
132929
132977
  }
132930
132978
  packagePath = ts.combinePaths(packagePath, subName);
132931
132979
  }
132932
- var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
132980
+ var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
132981
+ var packageFile = ts.combinePaths(packageDirectory, "package.json");
132933
132982
  if (ts.tryFileExists(host, packageFile)) {
132934
132983
  var packageJson = ts.readJson(packageFile, host);
132935
- var exports = packageJson.exports;
132936
- if (exports) {
132937
- if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
132984
+ var exports_1 = packageJson.exports;
132985
+ if (exports_1) {
132986
+ if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
132938
132987
  return; // null exports or entrypoint only, no sub-modules available
132939
132988
  }
132940
- var keys = ts.getOwnKeys(exports);
132941
- var fragmentSubpath_1 = components.join("/");
132942
- var processedKeys = ts.mapDefined(keys, function (k) {
132943
- if (k === ".")
132944
- return undefined;
132945
- if (!ts.startsWith(k, "./"))
132946
- return undefined;
132947
- var subpath = k.substring(2);
132948
- if (!ts.startsWith(subpath, fragmentSubpath_1))
132949
- return undefined;
132950
- // subpath is a valid export (barring conditions, which we don't currently check here)
132951
- if (!ts.stringContains(subpath, "*")) {
132952
- return subpath;
132953
- }
132954
- // pattern export - only return everything up to the `*`, so the user can autocomplete, then
132955
- // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
132956
- // but conditions will make that somewhat awkward, as each condition may have a different set of possible
132957
- // options for the `*`.
132958
- return subpath.slice(0, subpath.indexOf("*"));
132959
- });
132960
- ts.forEach(processedKeys, function (k) {
132961
- if (k) {
132962
- result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
132963
- }
132964
- });
132989
+ var keys = ts.getOwnKeys(exports_1);
132990
+ var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : "");
132991
+ var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
132992
+ addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys);
132965
132993
  return;
132966
132994
  }
132967
132995
  }
@@ -132971,31 +132999,44 @@ var ts;
132971
132999
  ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
132972
133000
  }
132973
133001
  }
132974
- return result;
133002
+ return ts.arrayFrom(result.values());
133003
+ }
133004
+ function getPatternFromFirstMatchingCondition(target, conditions) {
133005
+ if (typeof target === "string") {
133006
+ return target;
133007
+ }
133008
+ if (target && typeof target === "object" && !ts.isArray(target)) {
133009
+ for (var condition in target) {
133010
+ if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) {
133011
+ var pattern = target[condition];
133012
+ return getPatternFromFirstMatchingCondition(pattern, conditions);
133013
+ }
133014
+ }
133015
+ }
132975
133016
  }
132976
133017
  function getFragmentDirectory(fragment) {
132977
133018
  return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
132978
133019
  }
132979
- function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) {
133020
+ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
132980
133021
  if (!ts.endsWith(path, "*")) {
132981
133022
  // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
132982
- return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
133023
+ return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
132983
133024
  }
132984
133025
  var pathPrefix = path.slice(0, path.length - 1);
132985
133026
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
132986
133027
  if (remainingFragment === undefined) {
132987
133028
  var starIsFullPathComponent = path[path.length - 2] === "/";
132988
- return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
133029
+ return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
132989
133030
  var name = _a.name, rest = __rest(_a, ["name"]);
132990
133031
  return (__assign({ name: pathPrefix + name }, rest));
132991
133032
  }); });
132992
133033
  }
132993
- return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
132994
- function justPathMappingName(name) {
132995
- return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
133034
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); });
133035
+ function justPathMappingName(name, kind) {
133036
+ return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray;
132996
133037
  }
132997
133038
  }
132998
- function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
133039
+ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
132999
133040
  if (!host.readDirectory) {
133000
133041
  return undefined;
133001
133042
  }
@@ -133014,21 +133055,33 @@ var ts;
133014
133055
  var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
133015
133056
  var normalizedSuffix = ts.normalizePath(parsed.suffix);
133016
133057
  // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
133017
- var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory));
133058
+ var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
133018
133059
  var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
133019
- // If we have a suffix, then we need to read the directory all the way down. We could create a glob
133020
- // that encodes the suffix, but we would have to escape the character "?" which readDirectory
133021
- // doesn't support. For now, this is safer but slower
133022
- var includeGlob = normalizedSuffix ? "**/*" : "./*";
133023
- var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133024
- var extension = ts.tryGetExtensionFromPath(match);
133025
- var name = trimPrefixAndSuffix(match);
133026
- return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension);
133027
- });
133028
- var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) {
133029
- var name = trimPrefixAndSuffix(dir);
133030
- return name === undefined ? undefined : directoryResult(name);
133060
+ // If we have a suffix, then we read the directory all the way down to avoid returning completions for
133061
+ // directories that don't contain files that would match the suffix. A previous comment here was concerned
133062
+ // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
133063
+ // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
133064
+ // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
133065
+ // interpreted as "any character" can only return *too many* results as compared to the literal
133066
+ // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
133067
+ // done.
133068
+ var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
133069
+ var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133070
+ var trimmedWithPattern = trimPrefixAndSuffix(match);
133071
+ if (trimmedWithPattern) {
133072
+ if (containsSlash(trimmedWithPattern)) {
133073
+ return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
133074
+ }
133075
+ var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension;
133076
+ return nameAndKind(name, "script" /* scriptElement */, extension);
133077
+ }
133031
133078
  });
133079
+ // If we had a suffix, we already recursively searched for all possible files that could match
133080
+ // it and returned the directories leading to those files. Otherwise, assume any directory could
133081
+ // have something valid to import.
133082
+ var directories = normalizedSuffix
133083
+ ? ts.emptyArray
133084
+ : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); });
133032
133085
  return __spreadArray(__spreadArray([], matches, true), directories, true);
133033
133086
  function trimPrefixAndSuffix(path) {
133034
133087
  var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
@@ -133071,10 +133124,10 @@ var ts;
133071
133124
  var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
133072
133125
  : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
133073
133126
  : ts.Debug.fail();
133074
- return addReplacementSpans(toComplete, range.pos + prefix.length, names);
133127
+ return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
133075
133128
  }
133076
133129
  function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
133077
- if (result === void 0) { result = []; }
133130
+ if (result === void 0) { result = createNameAndKindSet(); }
133078
133131
  // Check for typings specified in compiler options
133079
133132
  var seen = new ts.Map();
133080
133133
  var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
@@ -133099,7 +133152,7 @@ var ts;
133099
133152
  continue;
133100
133153
  if (fragmentDirectory === undefined) {
133101
133154
  if (!seen.has(packageName)) {
133102
- result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133155
+ result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133103
133156
  seen.set(packageName, true);
133104
133157
  }
133105
133158
  }
@@ -138700,7 +138753,7 @@ var ts;
138700
138753
  result = references;
138701
138754
  continue;
138702
138755
  }
138703
- var _loop_4 = function (entry) {
138756
+ var _loop_3 = function (entry) {
138704
138757
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
138705
138758
  result.push(entry);
138706
138759
  return "continue";
@@ -138732,7 +138785,7 @@ var ts;
138732
138785
  };
138733
138786
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
138734
138787
  var entry = references_2[_b];
138735
- _loop_4(entry);
138788
+ _loop_3(entry);
138736
138789
  }
138737
138790
  }
138738
138791
  return result;
@@ -140313,8 +140366,8 @@ var ts;
140313
140366
  var declarations;
140314
140367
  if (symbol && symbol.declarations) {
140315
140368
  var indices = ts.indicesOf(symbol.declarations);
140316
- var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140317
- indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; });
140369
+ var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140370
+ indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; });
140318
140371
  var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
140319
140372
  var lastDecl = void 0;
140320
140373
  for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
@@ -140762,7 +140815,7 @@ var ts;
140762
140815
  }
140763
140816
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
140764
140817
  var allFiles = program.getSourceFiles();
140765
- var _loop_5 = function (sourceFile) {
140818
+ var _loop_4 = function (sourceFile) {
140766
140819
  var newFromOld = oldToNew(sourceFile.fileName);
140767
140820
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
140768
140821
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -140794,7 +140847,7 @@ var ts;
140794
140847
  };
140795
140848
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
140796
140849
  var sourceFile = allFiles_1[_i];
140797
- _loop_5(sourceFile);
140850
+ _loop_4(sourceFile);
140798
140851
  }
140799
140852
  }
140800
140853
  function combineNormal(pathA, pathB) {
@@ -141818,7 +141871,7 @@ var ts;
141818
141871
  if (!patternMatcher)
141819
141872
  return ts.emptyArray;
141820
141873
  var rawItems = [];
141821
- var _loop_6 = function (sourceFile) {
141874
+ var _loop_5 = function (sourceFile) {
141822
141875
  cancellationToken.throwIfCancellationRequested();
141823
141876
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
141824
141877
  return "continue";
@@ -141830,7 +141883,7 @@ var ts;
141830
141883
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
141831
141884
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
141832
141885
  var sourceFile = sourceFiles_4[_i];
141833
- _loop_6(sourceFile);
141886
+ _loop_5(sourceFile);
141834
141887
  }
141835
141888
  rawItems.sort(compareNavigateToItems);
141836
141889
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -143893,13 +143946,13 @@ var ts;
143893
143946
  // Assumes 'value' is already lowercase.
143894
143947
  function indexOfIgnoringCase(str, value) {
143895
143948
  var n = str.length - value.length;
143896
- var _loop_7 = function (start) {
143949
+ var _loop_6 = function (start) {
143897
143950
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
143898
143951
  return { value: start };
143899
143952
  }
143900
143953
  };
143901
143954
  for (var start = 0; start <= n; start++) {
143902
- var state_3 = _loop_7(start);
143955
+ var state_3 = _loop_6(start);
143903
143956
  if (typeof state_3 === "object")
143904
143957
  return state_3.value;
143905
143958
  }
@@ -145366,7 +145419,7 @@ var ts;
145366
145419
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
145367
145420
  }
145368
145421
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
145369
- var _loop_8 = function (n) {
145422
+ var _loop_7 = function (n) {
145370
145423
  // If the node is not a subspan of its parent, this is a big problem.
145371
145424
  // There have been crashes that might be caused by this violation.
145372
145425
  ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
@@ -145376,7 +145429,7 @@ var ts;
145376
145429
  }
145377
145430
  };
145378
145431
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
145379
- var state_4 = _loop_8(n);
145432
+ var state_4 = _loop_7(n);
145380
145433
  if (typeof state_4 === "object")
145381
145434
  return state_4.value;
145382
145435
  }
@@ -146989,7 +147042,7 @@ var ts;
146989
147042
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
146990
147043
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
146991
147044
  options = ts.cloneCompilerOptions(options);
146992
- var _loop_9 = function (opt) {
147045
+ var _loop_8 = function (opt) {
146993
147046
  if (!ts.hasProperty(options, opt.name)) {
146994
147047
  return "continue";
146995
147048
  }
@@ -147008,7 +147061,7 @@ var ts;
147008
147061
  };
147009
147062
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
147010
147063
  var opt = commandLineOptionsStringToEnum_1[_i];
147011
- _loop_9(opt);
147064
+ _loop_8(opt);
147012
147065
  }
147013
147066
  return options;
147014
147067
  }
@@ -150773,7 +150826,7 @@ var ts;
150773
150826
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
150774
150827
  var _this = this;
150775
150828
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
150776
- var _loop_10 = function (sourceFile, node) {
150829
+ var _loop_9 = function (sourceFile, node) {
150777
150830
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
150778
150831
  if (ts.isArray(node)) {
150779
150832
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -150786,7 +150839,7 @@ var ts;
150786
150839
  var this_1 = this;
150787
150840
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
150788
150841
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
150789
- _loop_10(sourceFile, node);
150842
+ _loop_9(sourceFile, node);
150790
150843
  }
150791
150844
  deletedNodesInLists.forEach(function (node) {
150792
150845
  var sourceFile = node.getSourceFile();
@@ -150874,14 +150927,14 @@ var ts;
150874
150927
  // order changes by start position
150875
150928
  // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
150876
150929
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
150877
- var _loop_11 = function (i) {
150930
+ var _loop_10 = function (i) {
150878
150931
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
150879
150932
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
150880
150933
  });
150881
150934
  };
150882
150935
  // verify that change intervals do not overlap, except possibly at end points.
150883
150936
  for (var i = 0; i < normalized.length - 1; i++) {
150884
- _loop_11(i);
150937
+ _loop_10(i);
150885
150938
  }
150886
150939
  var textChanges = ts.mapDefined(normalized, function (c) {
150887
150940
  var span = ts.createTextSpanFromRange(c.range);
@@ -151789,7 +151842,7 @@ var ts;
151789
151842
  }
151790
151843
  var isCompleteFix = identifiers.isCompleteFix;
151791
151844
  var initializers;
151792
- var _loop_12 = function (identifier) {
151845
+ var _loop_11 = function (identifier) {
151793
151846
  var symbol = checker.getSymbolAtLocation(identifier);
151794
151847
  if (!symbol) {
151795
151848
  return "continue";
@@ -151822,7 +151875,7 @@ var ts;
151822
151875
  };
151823
151876
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
151824
151877
  var identifier = _a[_i];
151825
- _loop_12(identifier);
151878
+ _loop_11(identifier);
151826
151879
  }
151827
151880
  return initializers && {
151828
151881
  initializers: initializers,
@@ -152707,7 +152760,7 @@ var ts;
152707
152760
  }
152708
152761
  var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
152709
152762
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
152710
- var _loop_13 = function (returnStatement) {
152763
+ var _loop_12 = function (returnStatement) {
152711
152764
  ts.forEachChild(returnStatement, function visit(node) {
152712
152765
  if (ts.isCallExpression(node)) {
152713
152766
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -152729,7 +152782,7 @@ var ts;
152729
152782
  };
152730
152783
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
152731
152784
  var returnStatement = returnStatements_1[_i];
152732
- var state_5 = _loop_13(returnStatement);
152785
+ var state_5 = _loop_12(returnStatement);
152733
152786
  if (typeof state_5 === "object")
152734
152787
  return state_5.value;
152735
152788
  }
@@ -156064,7 +156117,7 @@ var ts;
156064
156117
  });
156065
156118
  typeDeclToMembers.forEach(function (infos, declaration) {
156066
156119
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
156067
- var _loop_14 = function (info) {
156120
+ var _loop_13 = function (info) {
156068
156121
  // If some superclass added this property, don't add it again.
156069
156122
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
156070
156123
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -156091,7 +156144,7 @@ var ts;
156091
156144
  };
156092
156145
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
156093
156146
  var info = infos_1[_i];
156094
- _loop_14(info);
156147
+ _loop_13(info);
156095
156148
  }
156096
156149
  });
156097
156150
  }));
@@ -158865,7 +158918,7 @@ var ts;
158865
158918
  function getSignatureFromCalls(calls) {
158866
158919
  var parameters = [];
158867
158920
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
158868
- var _loop_15 = function (i) {
158921
+ var _loop_14 = function (i) {
158869
158922
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
158870
158923
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
158871
158924
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -158874,7 +158927,7 @@ var ts;
158874
158927
  parameters.push(symbol);
158875
158928
  };
158876
158929
  for (var i = 0; i < length; i++) {
158877
- _loop_15(i);
158930
+ _loop_14(i);
158878
158931
  }
158879
158932
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
158880
158933
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -160850,7 +160903,7 @@ var ts;
160850
160903
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
160851
160904
  // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`.
160852
160905
  var neededNamedImports = new ts.Set();
160853
- var _loop_16 = function (element) {
160906
+ var _loop_15 = function (element) {
160854
160907
  var propertyName = (element.propertyName || element.name).text;
160855
160908
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
160856
160909
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -160867,7 +160920,7 @@ var ts;
160867
160920
  };
160868
160921
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
160869
160922
  var element = _a[_i];
160870
- _loop_16(element);
160923
+ _loop_15(element);
160871
160924
  }
160872
160925
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
160873
160926
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -162758,7 +162811,7 @@ var ts;
162758
162811
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
162759
162812
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
162760
162813
  }
162761
- var _loop_17 = function (i) {
162814
+ var _loop_16 = function (i) {
162762
162815
  var scopeUsages = usagesPerScope[i];
162763
162816
  // Special case: in the innermost scope, all usages are available.
162764
162817
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -162801,7 +162854,7 @@ var ts;
162801
162854
  }
162802
162855
  };
162803
162856
  for (var i = 0; i < scopes.length; i++) {
162804
- _loop_17(i);
162857
+ _loop_16(i);
162805
162858
  }
162806
162859
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
162807
162860
  function isInGenericContext(node) {
@@ -163502,10 +163555,10 @@ var ts;
163502
163555
  }
163503
163556
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
163504
163557
  var checker = program.getTypeChecker();
163505
- var _loop_18 = function (sourceFile) {
163558
+ var _loop_17 = function (sourceFile) {
163506
163559
  if (sourceFile === oldFile)
163507
163560
  return "continue";
163508
- var _loop_19 = function (statement) {
163561
+ var _loop_18 = function (statement) {
163509
163562
  forEachImportInStatement(statement, function (importNode) {
163510
163563
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
163511
163564
  return;
@@ -163527,12 +163580,12 @@ var ts;
163527
163580
  };
163528
163581
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
163529
163582
  var statement = _c[_b];
163530
- _loop_19(statement);
163583
+ _loop_18(statement);
163531
163584
  }
163532
163585
  };
163533
163586
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
163534
163587
  var sourceFile = _a[_i];
163535
- _loop_18(sourceFile);
163588
+ _loop_17(sourceFile);
163536
163589
  }
163537
163590
  }
163538
163591
  function getNamespaceLikeImport(node) {
@@ -164895,7 +164948,7 @@ var ts;
164895
164948
  var templateSpans = [];
164896
164949
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
164897
164950
  copyCommentFromStringLiterals(headIndexes, templateHead);
164898
- var _loop_20 = function (i) {
164951
+ var _loop_19 = function (i) {
164899
164952
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
164900
164953
  copyOperatorComments(i, currentNode);
164901
164954
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -164924,7 +164977,7 @@ var ts;
164924
164977
  };
164925
164978
  var out_i_1;
164926
164979
  for (var i = begin; i < nodes.length; i++) {
164927
- _loop_20(i);
164980
+ _loop_19(i);
164928
164981
  i = out_i_1;
164929
164982
  }
164930
164983
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -165770,7 +165823,7 @@ var ts;
165770
165823
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
165771
165824
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
165772
165825
  var seenSymbols_1 = new ts.Set();
165773
- var _loop_21 = function (declaration) {
165826
+ var _loop_20 = function (declaration) {
165774
165827
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
165775
165828
  var _a;
165776
165829
  if (!seenSymbols_1.has(symbol)) {
@@ -165787,7 +165840,7 @@ var ts;
165787
165840
  };
165788
165841
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165789
165842
  var declaration = declarations_7[_i];
165790
- _loop_21(declaration);
165843
+ _loop_20(declaration);
165791
165844
  }
165792
165845
  }
165793
165846
  return tags;
@@ -165798,7 +165851,7 @@ var ts;
165798
165851
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
165799
165852
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
165800
165853
  var seenSymbols_2 = new ts.Set();
165801
- var _loop_22 = function (declaration) {
165854
+ var _loop_21 = function (declaration) {
165802
165855
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
165803
165856
  if (!seenSymbols_2.has(symbol)) {
165804
165857
  seenSymbols_2.add(symbol);
@@ -165814,7 +165867,7 @@ var ts;
165814
165867
  };
165815
165868
  for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
165816
165869
  var declaration = declarations_8[_i];
165817
- _loop_22(declaration);
165870
+ _loop_21(declaration);
165818
165871
  }
165819
165872
  }
165820
165873
  return doc;