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.
@@ -303,7 +303,7 @@ var ts;
303
303
  // The following is baselined as a literal template type without intervention
304
304
  /** The version of the TypeScript compiler release */
305
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-dev.20220707";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220710";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -2259,7 +2259,7 @@ var ts;
2259
2259
  * and 1 insertion/deletion at 3 characters)
2260
2260
  */
2261
2261
  function getSpellingSuggestion(name, candidates, getName) {
2262
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2262
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
2263
2263
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2264
2264
  var bestCandidate;
2265
2265
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -9243,6 +9243,7 @@ var ts;
9243
9243
  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'."),
9244
9244
  _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?"),
9245
9245
  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."),
9246
+ 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."),
9246
9247
  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}'."),
9247
9248
  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}'."),
9248
9249
  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}'."),
@@ -44622,6 +44623,7 @@ var ts;
44622
44623
  return toSearchResult(/*value*/ undefined);
44623
44624
  }
44624
44625
  /**
44626
+ * @internal
44625
44627
  * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44626
44628
  * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44627
44629
  */
@@ -44644,6 +44646,7 @@ var ts;
44644
44646
  return 1;
44645
44647
  return 0;
44646
44648
  }
44649
+ ts.comparePatternKeys = comparePatternKeys;
44647
44650
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44648
44651
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44649
44652
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -50450,6 +50453,7 @@ var ts;
50450
50453
  if (ctor && ctor.locals) {
50451
50454
  if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
50452
50455
  // Remember the property node, it will be used later to report appropriate error
50456
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
50453
50457
  propertyWithInvalidInitializer = location;
50454
50458
  }
50455
50459
  }
@@ -50639,11 +50643,27 @@ var ts;
50639
50643
  }
50640
50644
  }
50641
50645
  }
50646
+ // The invalid initializer error is needed in two situation:
50647
+ // 1. When result is undefined, after checking for a missing "this."
50648
+ // 2. When result is defined
50649
+ function checkAndReportErrorForInvalidInitializer() {
50650
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50651
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
50652
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50653
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
50654
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
50655
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
50656
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
50657
+ return true;
50658
+ }
50659
+ return false;
50660
+ }
50642
50661
  if (!result) {
50643
50662
  if (nameNotFoundMessage) {
50644
50663
  addLazyDiagnostic(function () {
50645
50664
  if (!errorLocation ||
50646
50665
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
50666
+ !checkAndReportErrorForInvalidInitializer() &&
50647
50667
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50648
50668
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50649
50669
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -50651,7 +50671,16 @@ var ts;
50651
50671
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50652
50672
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50653
50673
  var suggestion = void 0;
50654
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50674
+ var suggestedLib = void 0;
50675
+ // Report missing lib first
50676
+ if (nameArg) {
50677
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
50678
+ if (suggestedLib) {
50679
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
50680
+ }
50681
+ }
50682
+ // then spelling suggestions
50683
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50655
50684
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
50656
50685
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
50657
50686
  if (isGlobalScopeAugmentationDeclaration) {
@@ -50670,16 +50699,9 @@ var ts;
50670
50699
  }
50671
50700
  }
50672
50701
  }
50673
- if (!suggestion) {
50674
- if (nameArg) {
50675
- var lib = getSuggestedLibForNonExistentName(nameArg);
50676
- if (lib) {
50677
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
50678
- }
50679
- else {
50680
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50681
- }
50682
- }
50702
+ // And then fall back to unspecified "not found"
50703
+ if (!suggestion && !suggestedLib && nameArg) {
50704
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50683
50705
  }
50684
50706
  suggestionCount++;
50685
50707
  }
@@ -50687,12 +50709,7 @@ var ts;
50687
50709
  }
50688
50710
  return undefined;
50689
50711
  }
50690
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50691
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
50692
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50693
- // with ESNext+useDefineForClassFields because the scope semantics are different.
50694
- var propertyName = propertyWithInvalidInitializer.name;
50695
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
50712
+ else if (checkAndReportErrorForInvalidInitializer()) {
50696
50713
  return undefined;
50697
50714
  }
50698
50715
  // Perform extra checks only if error reporting was requested
@@ -62559,19 +62576,22 @@ var ts;
62559
62576
  * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
62560
62577
  */
62561
62578
  function isPossiblyReducibleByInstantiation(type) {
62562
- return ts.some(type.types, function (t) {
62563
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
62564
- return getReducedType(uniqueFilled) !== uniqueFilled;
62565
- });
62579
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
62580
+ return getReducedType(uniqueFilled) !== uniqueFilled;
62581
+ }
62582
+ function shouldDeferIndexType(type) {
62583
+ return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
62584
+ isGenericTupleType(type) ||
62585
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
62586
+ type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
62587
+ type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
62566
62588
  }
62567
62589
  function getIndexType(type, stringsOnly, noIndexSignatures) {
62568
62590
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
62569
62591
  type = getReducedType(type);
62570
- return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
62571
- ? getIndexTypeForGenericType(type, stringsOnly)
62572
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62573
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62574
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62592
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62593
+ type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62594
+ type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62575
62595
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
62576
62596
  type === wildcardType ? wildcardType :
62577
62597
  type.flags & 2 /* Unknown */ ? neverType :
@@ -70161,6 +70181,15 @@ var ts;
70161
70181
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
70162
70182
  return key && key + "." + propName;
70163
70183
  }
70184
+ break;
70185
+ case 201 /* ObjectBindingPattern */:
70186
+ case 202 /* ArrayBindingPattern */:
70187
+ case 256 /* FunctionDeclaration */:
70188
+ case 213 /* FunctionExpression */:
70189
+ case 214 /* ArrowFunction */:
70190
+ case 169 /* MethodDeclaration */:
70191
+ // Handle pseudo-references originating in getNarrowedTypeOfSymbol.
70192
+ return getNodeId(node) + "#" + getTypeId(declaredType);
70164
70193
  }
70165
70194
  return undefined;
70166
70195
  }
@@ -132993,6 +133022,26 @@ var ts;
132993
133022
  (function (Completions) {
132994
133023
  var StringCompletions;
132995
133024
  (function (StringCompletions) {
133025
+ var _a;
133026
+ var kindPrecedence = (_a = {},
133027
+ _a["directory" /* directory */] = 0,
133028
+ _a["script" /* scriptElement */] = 1,
133029
+ _a["external module name" /* externalModuleName */] = 2,
133030
+ _a);
133031
+ function createNameAndKindSet() {
133032
+ var map = new ts.Map();
133033
+ function add(value) {
133034
+ var existing = map.get(value.name);
133035
+ if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
133036
+ map.set(value.name, value);
133037
+ }
133038
+ }
133039
+ return {
133040
+ add: add,
133041
+ has: map.has.bind(map),
133042
+ values: map.values.bind(map),
133043
+ };
133044
+ }
132996
133045
  function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
132997
133046
  if (ts.isInReferenceComment(sourceFile, position)) {
132998
133047
  var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
@@ -133274,11 +133323,12 @@ var ts;
133274
133323
  }
133275
133324
  function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
133276
133325
  var literalValue = ts.normalizeSlashes(node.text);
133326
+ var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
133277
133327
  var scriptPath = sourceFile.path;
133278
133328
  var scriptDirectory = ts.getDirectoryPath(scriptPath);
133279
133329
  return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
133280
133330
  ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
133281
- : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
133331
+ : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
133282
133332
  function getIncludeExtensionOption() {
133283
133333
  var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
133284
133334
  return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
@@ -133294,7 +133344,7 @@ var ts;
133294
133344
  return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
133295
133345
  }
133296
133346
  else {
133297
- return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
133347
+ return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
133298
133348
  }
133299
133349
  }
133300
133350
  function isEmitResolutionKindUsingNodeModules(compilerOptions) {
@@ -133330,7 +133380,7 @@ var ts;
133330
133380
  var basePath = compilerOptions.project || host.getCurrentDirectory();
133331
133381
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
133332
133382
  var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
133333
- return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); });
133383
+ return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); });
133334
133384
  }
133335
133385
  var IncludeExtensionsOption;
133336
133386
  (function (IncludeExtensionsOption) {
@@ -133341,10 +133391,9 @@ var ts;
133341
133391
  /**
133342
133392
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
133343
133393
  */
133344
- function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
133345
- var _b;
133346
- var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
133347
- if (result === void 0) { result = []; }
133394
+ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
133395
+ var _a;
133396
+ if (result === void 0) { result = createNameAndKindSet(); }
133348
133397
  if (fragment === undefined) {
133349
133398
  fragment = "";
133350
133399
  }
@@ -133368,11 +133417,11 @@ var ts;
133368
133417
  var packageJson = ts.readJson(packageJsonPath, host);
133369
133418
  var typesVersions = packageJson.typesVersions;
133370
133419
  if (typeof typesVersions === "object") {
133371
- var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
133420
+ var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
133372
133421
  if (versionPaths) {
133373
133422
  var packageDirectory = ts.getDirectoryPath(packageJsonPath);
133374
133423
  var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
133375
- if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
133424
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
133376
133425
  // A true result means one of the `versionPaths` was matched, which will block relative resolution
133377
133426
  // to files and folders from here. All reachable paths given the pattern match are already added.
133378
133427
  return result;
@@ -133384,39 +133433,17 @@ var ts;
133384
133433
  if (!ts.tryDirectoryExists(host, baseDirectory))
133385
133434
  return result;
133386
133435
  // Enumerate the available files if possible
133387
- var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
133436
+ var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
133388
133437
  if (files) {
133389
- /**
133390
- * Multiple file entries might map to the same truncated name once we remove extensions
133391
- * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
133392
- *
133393
- * both foo.ts and foo.tsx become foo
133394
- */
133395
- var foundFiles = new ts.Map(); // maps file to its extension
133396
133438
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
133397
133439
  var filePath = files_1[_i];
133398
133440
  filePath = ts.normalizePath(filePath);
133399
133441
  if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
133400
133442
  continue;
133401
133443
  }
133402
- var foundFileName = void 0;
133403
- var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
133404
- if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
133405
- foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
133406
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
133407
- }
133408
- else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
133409
- foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
133410
- foundFiles.set(foundFileName, outputExtension);
133411
- }
133412
- else {
133413
- foundFileName = ts.getBaseFileName(filePath);
133414
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
133415
- }
133444
+ var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension;
133445
+ result.add(nameAndKind(name, "script" /* scriptElement */, extension));
133416
133446
  }
133417
- foundFiles.forEach(function (ext, foundFile) {
133418
- result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
133419
- });
133420
133447
  }
133421
133448
  // If possible, get folder completion as well
133422
133449
  var directories = ts.tryGetDirectories(host, baseDirectory);
@@ -133425,27 +133452,52 @@ var ts;
133425
133452
  var directory = directories_1[_c];
133426
133453
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
133427
133454
  if (directoryName !== "@types") {
133428
- result.push(directoryResult(directoryName));
133455
+ result.add(directoryResult(directoryName));
133429
133456
  }
133430
133457
  }
133431
133458
  }
133432
133459
  return result;
133433
133460
  }
133461
+ function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) {
133462
+ var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
133463
+ if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
133464
+ return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) };
133465
+ }
133466
+ else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
133467
+ return { name: ts.changeExtension(name, outputExtension), extension: outputExtension };
133468
+ }
133469
+ else {
133470
+ return { name: name, extension: ts.tryGetExtensionFromPath(name) };
133471
+ }
133472
+ }
133434
133473
  /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
133435
- function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
133436
- var _a;
133474
+ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
133475
+ var getPatternsForKey = function (key) { return paths[key]; };
133476
+ var comparePaths = function (a, b) {
133477
+ var patternA = ts.tryParsePattern(a);
133478
+ var patternB = ts.tryParsePattern(b);
133479
+ var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
133480
+ var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
133481
+ return ts.compareValues(lengthB, lengthA);
133482
+ };
133483
+ return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths);
133484
+ }
133485
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
133486
+ function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) {
133437
133487
  var pathResults = [];
133438
- var matchedPathPrefixLength = -1;
133439
- for (var path in paths) {
133440
- if (!ts.hasProperty(paths, path))
133488
+ var matchedPath;
133489
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
133490
+ var key = keys_1[_i];
133491
+ if (key === ".")
133441
133492
  continue;
133442
- var patterns = paths[path];
133493
+ var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
133494
+ var patterns = getPatternsForKey(key);
133443
133495
  if (patterns) {
133444
- var pathPattern = ts.tryParsePattern(path);
133496
+ var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
133445
133497
  if (!pathPattern)
133446
133498
  continue;
133447
133499
  var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
133448
- var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
133500
+ var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
133449
133501
  if (isLongestMatch) {
133450
133502
  // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
133451
133503
  // for `import {} from "some-package/|"` with a typesVersions:
@@ -133458,13 +133510,13 @@ var ts;
133458
133510
  // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
133459
133511
  // ./dist/foo and ./foo, when only the latter will actually be resolvable.
133460
133512
  // See pathCompletionsTypesVersionsWildcard6.ts.
133461
- matchedPathPrefixLength = pathPattern.prefix.length;
133513
+ matchedPath = key;
133462
133514
  pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
133463
133515
  }
133464
- if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
133516
+ if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
133465
133517
  pathResults.push({
133466
133518
  matchedPattern: isMatch,
133467
- results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
133519
+ results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
133468
133520
  .map(function (_a) {
133469
133521
  var name = _a.name, kind = _a.kind, extension = _a.extension;
133470
133522
  return nameAndKind(name, kind, extension);
@@ -133473,10 +133525,8 @@ var ts;
133473
133525
  }
133474
133526
  }
133475
133527
  }
133476
- var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
133477
- var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
133478
- pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
133479
- return matchedPathPrefixLength > -1;
133528
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
133529
+ return matchedPath !== undefined;
133480
133530
  }
133481
133531
  /**
133482
133532
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -133485,22 +133535,22 @@ var ts;
133485
133535
  * Modules from node_modules (i.e. those listed in package.json)
133486
133536
  * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
133487
133537
  */
133488
- function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
133538
+ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
133489
133539
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
133490
- var result = [];
133491
- var extensionOptions = getExtensionOptions(compilerOptions);
133540
+ var result = createNameAndKindSet();
133541
+ var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
133492
133542
  if (baseUrl) {
133493
133543
  var projectDir = compilerOptions.project || host.getCurrentDirectory();
133494
133544
  var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
133495
133545
  getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
133496
133546
  if (paths) {
133497
- addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host);
133547
+ addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
133498
133548
  }
133499
133549
  }
133500
133550
  var fragmentDirectory = getFragmentDirectory(fragment);
133501
133551
  for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
133502
133552
  var ambientName = _a[_i];
133503
- result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133553
+ result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133504
133554
  }
133505
133555
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
133506
133556
  if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
@@ -133508,15 +133558,13 @@ var ts;
133508
133558
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
133509
133559
  var foundGlobal = false;
133510
133560
  if (fragmentDirectory === undefined) {
133511
- var _loop_3 = function (moduleName) {
133512
- if (!result.some(function (entry) { return entry.name === moduleName; })) {
133513
- foundGlobal = true;
133514
- result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133515
- }
133516
- };
133517
133561
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
133518
133562
  var moduleName = _c[_b];
133519
- _loop_3(moduleName);
133563
+ var moduleResult = nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined);
133564
+ if (!result.has(moduleResult.name)) {
133565
+ foundGlobal = true;
133566
+ result.add(moduleResult);
133567
+ }
133520
133568
  }
133521
133569
  }
133522
133570
  if (!foundGlobal) {
@@ -133542,39 +133590,19 @@ var ts;
133542
133590
  }
133543
133591
  packagePath = ts.combinePaths(packagePath, subName);
133544
133592
  }
133545
- var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
133593
+ var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
133594
+ var packageFile = ts.combinePaths(packageDirectory, "package.json");
133546
133595
  if (ts.tryFileExists(host, packageFile)) {
133547
133596
  var packageJson = ts.readJson(packageFile, host);
133548
- var exports = packageJson.exports;
133549
- if (exports) {
133550
- if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
133597
+ var exports_1 = packageJson.exports;
133598
+ if (exports_1) {
133599
+ if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
133551
133600
  return; // null exports or entrypoint only, no sub-modules available
133552
133601
  }
133553
- var keys = ts.getOwnKeys(exports);
133554
- var fragmentSubpath_1 = components.join("/");
133555
- var processedKeys = ts.mapDefined(keys, function (k) {
133556
- if (k === ".")
133557
- return undefined;
133558
- if (!ts.startsWith(k, "./"))
133559
- return undefined;
133560
- var subpath = k.substring(2);
133561
- if (!ts.startsWith(subpath, fragmentSubpath_1))
133562
- return undefined;
133563
- // subpath is a valid export (barring conditions, which we don't currently check here)
133564
- if (!ts.stringContains(subpath, "*")) {
133565
- return subpath;
133566
- }
133567
- // pattern export - only return everything up to the `*`, so the user can autocomplete, then
133568
- // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
133569
- // but conditions will make that somewhat awkward, as each condition may have a different set of possible
133570
- // options for the `*`.
133571
- return subpath.slice(0, subpath.indexOf("*"));
133572
- });
133573
- ts.forEach(processedKeys, function (k) {
133574
- if (k) {
133575
- result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
133576
- }
133577
- });
133602
+ var keys = ts.getOwnKeys(exports_1);
133603
+ var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : "");
133604
+ var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
133605
+ addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys);
133578
133606
  return;
133579
133607
  }
133580
133608
  }
@@ -133584,31 +133612,44 @@ var ts;
133584
133612
  ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
133585
133613
  }
133586
133614
  }
133587
- return result;
133615
+ return ts.arrayFrom(result.values());
133616
+ }
133617
+ function getPatternFromFirstMatchingCondition(target, conditions) {
133618
+ if (typeof target === "string") {
133619
+ return target;
133620
+ }
133621
+ if (target && typeof target === "object" && !ts.isArray(target)) {
133622
+ for (var condition in target) {
133623
+ if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) {
133624
+ var pattern = target[condition];
133625
+ return getPatternFromFirstMatchingCondition(pattern, conditions);
133626
+ }
133627
+ }
133628
+ }
133588
133629
  }
133589
133630
  function getFragmentDirectory(fragment) {
133590
133631
  return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
133591
133632
  }
133592
- function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) {
133633
+ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
133593
133634
  if (!ts.endsWith(path, "*")) {
133594
133635
  // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
133595
- return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
133636
+ return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
133596
133637
  }
133597
133638
  var pathPrefix = path.slice(0, path.length - 1);
133598
133639
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
133599
133640
  if (remainingFragment === undefined) {
133600
133641
  var starIsFullPathComponent = path[path.length - 2] === "/";
133601
- 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) {
133642
+ 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) {
133602
133643
  var name = _a.name, rest = __rest(_a, ["name"]);
133603
133644
  return (__assign({ name: pathPrefix + name }, rest));
133604
133645
  }); });
133605
133646
  }
133606
- return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
133607
- function justPathMappingName(name) {
133608
- return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
133647
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); });
133648
+ function justPathMappingName(name, kind) {
133649
+ return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray;
133609
133650
  }
133610
133651
  }
133611
- function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
133652
+ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
133612
133653
  if (!host.readDirectory) {
133613
133654
  return undefined;
133614
133655
  }
@@ -133627,21 +133668,33 @@ var ts;
133627
133668
  var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
133628
133669
  var normalizedSuffix = ts.normalizePath(parsed.suffix);
133629
133670
  // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
133630
- var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory));
133671
+ var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
133631
133672
  var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
133632
- // If we have a suffix, then we need to read the directory all the way down. We could create a glob
133633
- // that encodes the suffix, but we would have to escape the character "?" which readDirectory
133634
- // doesn't support. For now, this is safer but slower
133635
- var includeGlob = normalizedSuffix ? "**/*" : "./*";
133636
- var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133637
- var extension = ts.tryGetExtensionFromPath(match);
133638
- var name = trimPrefixAndSuffix(match);
133639
- return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension);
133640
- });
133641
- var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) {
133642
- var name = trimPrefixAndSuffix(dir);
133643
- return name === undefined ? undefined : directoryResult(name);
133673
+ // If we have a suffix, then we read the directory all the way down to avoid returning completions for
133674
+ // directories that don't contain files that would match the suffix. A previous comment here was concerned
133675
+ // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
133676
+ // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
133677
+ // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
133678
+ // interpreted as "any character" can only return *too many* results as compared to the literal
133679
+ // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
133680
+ // done.
133681
+ var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
133682
+ var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133683
+ var trimmedWithPattern = trimPrefixAndSuffix(match);
133684
+ if (trimmedWithPattern) {
133685
+ if (containsSlash(trimmedWithPattern)) {
133686
+ return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
133687
+ }
133688
+ var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension;
133689
+ return nameAndKind(name, "script" /* scriptElement */, extension);
133690
+ }
133644
133691
  });
133692
+ // If we had a suffix, we already recursively searched for all possible files that could match
133693
+ // it and returned the directories leading to those files. Otherwise, assume any directory could
133694
+ // have something valid to import.
133695
+ var directories = normalizedSuffix
133696
+ ? ts.emptyArray
133697
+ : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); });
133645
133698
  return __spreadArray(__spreadArray([], matches, true), directories, true);
133646
133699
  function trimPrefixAndSuffix(path) {
133647
133700
  var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
@@ -133684,10 +133737,10 @@ var ts;
133684
133737
  var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
133685
133738
  : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
133686
133739
  : ts.Debug.fail();
133687
- return addReplacementSpans(toComplete, range.pos + prefix.length, names);
133740
+ return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
133688
133741
  }
133689
133742
  function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
133690
- if (result === void 0) { result = []; }
133743
+ if (result === void 0) { result = createNameAndKindSet(); }
133691
133744
  // Check for typings specified in compiler options
133692
133745
  var seen = new ts.Map();
133693
133746
  var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
@@ -133712,7 +133765,7 @@ var ts;
133712
133765
  continue;
133713
133766
  if (fragmentDirectory === undefined) {
133714
133767
  if (!seen.has(packageName)) {
133715
- result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133768
+ result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133716
133769
  seen.set(packageName, true);
133717
133770
  }
133718
133771
  }
@@ -139313,7 +139366,7 @@ var ts;
139313
139366
  result = references;
139314
139367
  continue;
139315
139368
  }
139316
- var _loop_4 = function (entry) {
139369
+ var _loop_3 = function (entry) {
139317
139370
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
139318
139371
  result.push(entry);
139319
139372
  return "continue";
@@ -139345,7 +139398,7 @@ var ts;
139345
139398
  };
139346
139399
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
139347
139400
  var entry = references_2[_b];
139348
- _loop_4(entry);
139401
+ _loop_3(entry);
139349
139402
  }
139350
139403
  }
139351
139404
  return result;
@@ -140926,8 +140979,8 @@ var ts;
140926
140979
  var declarations;
140927
140980
  if (symbol && symbol.declarations) {
140928
140981
  var indices = ts.indicesOf(symbol.declarations);
140929
- var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140930
- indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; });
140982
+ var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140983
+ indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; });
140931
140984
  var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
140932
140985
  var lastDecl = void 0;
140933
140986
  for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
@@ -141375,7 +141428,7 @@ var ts;
141375
141428
  }
141376
141429
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
141377
141430
  var allFiles = program.getSourceFiles();
141378
- var _loop_5 = function (sourceFile) {
141431
+ var _loop_4 = function (sourceFile) {
141379
141432
  var newFromOld = oldToNew(sourceFile.fileName);
141380
141433
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
141381
141434
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -141407,7 +141460,7 @@ var ts;
141407
141460
  };
141408
141461
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
141409
141462
  var sourceFile = allFiles_1[_i];
141410
- _loop_5(sourceFile);
141463
+ _loop_4(sourceFile);
141411
141464
  }
141412
141465
  }
141413
141466
  function combineNormal(pathA, pathB) {
@@ -142431,7 +142484,7 @@ var ts;
142431
142484
  if (!patternMatcher)
142432
142485
  return ts.emptyArray;
142433
142486
  var rawItems = [];
142434
- var _loop_6 = function (sourceFile) {
142487
+ var _loop_5 = function (sourceFile) {
142435
142488
  cancellationToken.throwIfCancellationRequested();
142436
142489
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
142437
142490
  return "continue";
@@ -142443,7 +142496,7 @@ var ts;
142443
142496
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
142444
142497
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
142445
142498
  var sourceFile = sourceFiles_4[_i];
142446
- _loop_6(sourceFile);
142499
+ _loop_5(sourceFile);
142447
142500
  }
142448
142501
  rawItems.sort(compareNavigateToItems);
142449
142502
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -144506,13 +144559,13 @@ var ts;
144506
144559
  // Assumes 'value' is already lowercase.
144507
144560
  function indexOfIgnoringCase(str, value) {
144508
144561
  var n = str.length - value.length;
144509
- var _loop_7 = function (start) {
144562
+ var _loop_6 = function (start) {
144510
144563
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
144511
144564
  return { value: start };
144512
144565
  }
144513
144566
  };
144514
144567
  for (var start = 0; start <= n; start++) {
144515
- var state_3 = _loop_7(start);
144568
+ var state_3 = _loop_6(start);
144516
144569
  if (typeof state_3 === "object")
144517
144570
  return state_3.value;
144518
144571
  }
@@ -145979,7 +146032,7 @@ var ts;
145979
146032
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
145980
146033
  }
145981
146034
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
145982
- var _loop_8 = function (n) {
146035
+ var _loop_7 = function (n) {
145983
146036
  // If the node is not a subspan of its parent, this is a big problem.
145984
146037
  // There have been crashes that might be caused by this violation.
145985
146038
  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); });
@@ -145989,7 +146042,7 @@ var ts;
145989
146042
  }
145990
146043
  };
145991
146044
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
145992
- var state_4 = _loop_8(n);
146045
+ var state_4 = _loop_7(n);
145993
146046
  if (typeof state_4 === "object")
145994
146047
  return state_4.value;
145995
146048
  }
@@ -147602,7 +147655,7 @@ var ts;
147602
147655
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
147603
147656
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
147604
147657
  options = ts.cloneCompilerOptions(options);
147605
- var _loop_9 = function (opt) {
147658
+ var _loop_8 = function (opt) {
147606
147659
  if (!ts.hasProperty(options, opt.name)) {
147607
147660
  return "continue";
147608
147661
  }
@@ -147621,7 +147674,7 @@ var ts;
147621
147674
  };
147622
147675
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
147623
147676
  var opt = commandLineOptionsStringToEnum_1[_i];
147624
- _loop_9(opt);
147677
+ _loop_8(opt);
147625
147678
  }
147626
147679
  return options;
147627
147680
  }
@@ -151386,7 +151439,7 @@ var ts;
151386
151439
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
151387
151440
  var _this = this;
151388
151441
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
151389
- var _loop_10 = function (sourceFile, node) {
151442
+ var _loop_9 = function (sourceFile, node) {
151390
151443
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
151391
151444
  if (ts.isArray(node)) {
151392
151445
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -151399,7 +151452,7 @@ var ts;
151399
151452
  var this_1 = this;
151400
151453
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
151401
151454
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
151402
- _loop_10(sourceFile, node);
151455
+ _loop_9(sourceFile, node);
151403
151456
  }
151404
151457
  deletedNodesInLists.forEach(function (node) {
151405
151458
  var sourceFile = node.getSourceFile();
@@ -151487,14 +151540,14 @@ var ts;
151487
151540
  // order changes by start position
151488
151541
  // 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.
151489
151542
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
151490
- var _loop_11 = function (i) {
151543
+ var _loop_10 = function (i) {
151491
151544
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
151492
151545
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
151493
151546
  });
151494
151547
  };
151495
151548
  // verify that change intervals do not overlap, except possibly at end points.
151496
151549
  for (var i = 0; i < normalized.length - 1; i++) {
151497
- _loop_11(i);
151550
+ _loop_10(i);
151498
151551
  }
151499
151552
  var textChanges = ts.mapDefined(normalized, function (c) {
151500
151553
  var span = ts.createTextSpanFromRange(c.range);
@@ -152402,7 +152455,7 @@ var ts;
152402
152455
  }
152403
152456
  var isCompleteFix = identifiers.isCompleteFix;
152404
152457
  var initializers;
152405
- var _loop_12 = function (identifier) {
152458
+ var _loop_11 = function (identifier) {
152406
152459
  var symbol = checker.getSymbolAtLocation(identifier);
152407
152460
  if (!symbol) {
152408
152461
  return "continue";
@@ -152435,7 +152488,7 @@ var ts;
152435
152488
  };
152436
152489
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
152437
152490
  var identifier = _a[_i];
152438
- _loop_12(identifier);
152491
+ _loop_11(identifier);
152439
152492
  }
152440
152493
  return initializers && {
152441
152494
  initializers: initializers,
@@ -153320,7 +153373,7 @@ var ts;
153320
153373
  }
153321
153374
  var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
153322
153375
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
153323
- var _loop_13 = function (returnStatement) {
153376
+ var _loop_12 = function (returnStatement) {
153324
153377
  ts.forEachChild(returnStatement, function visit(node) {
153325
153378
  if (ts.isCallExpression(node)) {
153326
153379
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -153342,7 +153395,7 @@ var ts;
153342
153395
  };
153343
153396
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
153344
153397
  var returnStatement = returnStatements_1[_i];
153345
- var state_5 = _loop_13(returnStatement);
153398
+ var state_5 = _loop_12(returnStatement);
153346
153399
  if (typeof state_5 === "object")
153347
153400
  return state_5.value;
153348
153401
  }
@@ -156677,7 +156730,7 @@ var ts;
156677
156730
  });
156678
156731
  typeDeclToMembers.forEach(function (infos, declaration) {
156679
156732
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
156680
- var _loop_14 = function (info) {
156733
+ var _loop_13 = function (info) {
156681
156734
  // If some superclass added this property, don't add it again.
156682
156735
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
156683
156736
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -156704,7 +156757,7 @@ var ts;
156704
156757
  };
156705
156758
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
156706
156759
  var info = infos_1[_i];
156707
- _loop_14(info);
156760
+ _loop_13(info);
156708
156761
  }
156709
156762
  });
156710
156763
  }));
@@ -159478,7 +159531,7 @@ var ts;
159478
159531
  function getSignatureFromCalls(calls) {
159479
159532
  var parameters = [];
159480
159533
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
159481
- var _loop_15 = function (i) {
159534
+ var _loop_14 = function (i) {
159482
159535
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
159483
159536
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
159484
159537
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -159487,7 +159540,7 @@ var ts;
159487
159540
  parameters.push(symbol);
159488
159541
  };
159489
159542
  for (var i = 0; i < length; i++) {
159490
- _loop_15(i);
159543
+ _loop_14(i);
159491
159544
  }
159492
159545
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
159493
159546
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -161463,7 +161516,7 @@ var ts;
161463
161516
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
161464
161517
  // 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 }`.
161465
161518
  var neededNamedImports = new ts.Set();
161466
- var _loop_16 = function (element) {
161519
+ var _loop_15 = function (element) {
161467
161520
  var propertyName = (element.propertyName || element.name).text;
161468
161521
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
161469
161522
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -161480,7 +161533,7 @@ var ts;
161480
161533
  };
161481
161534
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
161482
161535
  var element = _a[_i];
161483
- _loop_16(element);
161536
+ _loop_15(element);
161484
161537
  }
161485
161538
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
161486
161539
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -163371,7 +163424,7 @@ var ts;
163371
163424
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
163372
163425
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
163373
163426
  }
163374
- var _loop_17 = function (i) {
163427
+ var _loop_16 = function (i) {
163375
163428
  var scopeUsages = usagesPerScope[i];
163376
163429
  // Special case: in the innermost scope, all usages are available.
163377
163430
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -163414,7 +163467,7 @@ var ts;
163414
163467
  }
163415
163468
  };
163416
163469
  for (var i = 0; i < scopes.length; i++) {
163417
- _loop_17(i);
163470
+ _loop_16(i);
163418
163471
  }
163419
163472
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
163420
163473
  function isInGenericContext(node) {
@@ -164115,10 +164168,10 @@ var ts;
164115
164168
  }
164116
164169
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
164117
164170
  var checker = program.getTypeChecker();
164118
- var _loop_18 = function (sourceFile) {
164171
+ var _loop_17 = function (sourceFile) {
164119
164172
  if (sourceFile === oldFile)
164120
164173
  return "continue";
164121
- var _loop_19 = function (statement) {
164174
+ var _loop_18 = function (statement) {
164122
164175
  forEachImportInStatement(statement, function (importNode) {
164123
164176
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
164124
164177
  return;
@@ -164140,12 +164193,12 @@ var ts;
164140
164193
  };
164141
164194
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
164142
164195
  var statement = _c[_b];
164143
- _loop_19(statement);
164196
+ _loop_18(statement);
164144
164197
  }
164145
164198
  };
164146
164199
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
164147
164200
  var sourceFile = _a[_i];
164148
- _loop_18(sourceFile);
164201
+ _loop_17(sourceFile);
164149
164202
  }
164150
164203
  }
164151
164204
  function getNamespaceLikeImport(node) {
@@ -165508,7 +165561,7 @@ var ts;
165508
165561
  var templateSpans = [];
165509
165562
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
165510
165563
  copyCommentFromStringLiterals(headIndexes, templateHead);
165511
- var _loop_20 = function (i) {
165564
+ var _loop_19 = function (i) {
165512
165565
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
165513
165566
  copyOperatorComments(i, currentNode);
165514
165567
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -165537,7 +165590,7 @@ var ts;
165537
165590
  };
165538
165591
  var out_i_1;
165539
165592
  for (var i = begin; i < nodes.length; i++) {
165540
- _loop_20(i);
165593
+ _loop_19(i);
165541
165594
  i = out_i_1;
165542
165595
  }
165543
165596
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -166383,7 +166436,7 @@ var ts;
166383
166436
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
166384
166437
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
166385
166438
  var seenSymbols_1 = new ts.Set();
166386
- var _loop_21 = function (declaration) {
166439
+ var _loop_20 = function (declaration) {
166387
166440
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
166388
166441
  var _a;
166389
166442
  if (!seenSymbols_1.has(symbol)) {
@@ -166400,7 +166453,7 @@ var ts;
166400
166453
  };
166401
166454
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
166402
166455
  var declaration = declarations_7[_i];
166403
- _loop_21(declaration);
166456
+ _loop_20(declaration);
166404
166457
  }
166405
166458
  }
166406
166459
  return tags;
@@ -166411,7 +166464,7 @@ var ts;
166411
166464
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
166412
166465
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
166413
166466
  var seenSymbols_2 = new ts.Set();
166414
- var _loop_22 = function (declaration) {
166467
+ var _loop_21 = function (declaration) {
166415
166468
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
166416
166469
  if (!seenSymbols_2.has(symbol)) {
166417
166470
  seenSymbols_2.add(symbol);
@@ -166427,7 +166480,7 @@ var ts;
166427
166480
  };
166428
166481
  for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
166429
166482
  var declaration = declarations_8[_i];
166430
- _loop_22(declaration);
166483
+ _loop_21(declaration);
166431
166484
  }
166432
166485
  }
166433
166486
  return doc;