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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220707";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220710";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2250,7 +2250,7 @@ var ts;
2250
2250
  * and 1 insertion/deletion at 3 characters)
2251
2251
  */
2252
2252
  function getSpellingSuggestion(name, candidates, getName) {
2253
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2253
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
2254
2254
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2255
2255
  var bestCandidate;
2256
2256
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -9234,6 +9234,7 @@ var ts;
9234
9234
  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'."),
9235
9235
  _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?"),
9236
9236
  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."),
9237
+ 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."),
9237
9238
  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}'."),
9238
9239
  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}'."),
9239
9240
  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}'."),
@@ -44613,6 +44614,7 @@ var ts;
44613
44614
  return toSearchResult(/*value*/ undefined);
44614
44615
  }
44615
44616
  /**
44617
+ * @internal
44616
44618
  * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44617
44619
  * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44618
44620
  */
@@ -44635,6 +44637,7 @@ var ts;
44635
44637
  return 1;
44636
44638
  return 0;
44637
44639
  }
44640
+ ts.comparePatternKeys = comparePatternKeys;
44638
44641
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44639
44642
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44640
44643
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -50441,6 +50444,7 @@ var ts;
50441
50444
  if (ctor && ctor.locals) {
50442
50445
  if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
50443
50446
  // Remember the property node, it will be used later to report appropriate error
50447
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
50444
50448
  propertyWithInvalidInitializer = location;
50445
50449
  }
50446
50450
  }
@@ -50630,11 +50634,27 @@ var ts;
50630
50634
  }
50631
50635
  }
50632
50636
  }
50637
+ // The invalid initializer error is needed in two situation:
50638
+ // 1. When result is undefined, after checking for a missing "this."
50639
+ // 2. When result is defined
50640
+ function checkAndReportErrorForInvalidInitializer() {
50641
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50642
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
50643
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50644
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
50645
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
50646
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
50647
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
50648
+ return true;
50649
+ }
50650
+ return false;
50651
+ }
50633
50652
  if (!result) {
50634
50653
  if (nameNotFoundMessage) {
50635
50654
  addLazyDiagnostic(function () {
50636
50655
  if (!errorLocation ||
50637
50656
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
50657
+ !checkAndReportErrorForInvalidInitializer() &&
50638
50658
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50639
50659
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50640
50660
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -50642,7 +50662,16 @@ var ts;
50642
50662
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50643
50663
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50644
50664
  var suggestion = void 0;
50645
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50665
+ var suggestedLib = void 0;
50666
+ // Report missing lib first
50667
+ if (nameArg) {
50668
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
50669
+ if (suggestedLib) {
50670
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
50671
+ }
50672
+ }
50673
+ // then spelling suggestions
50674
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50646
50675
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
50647
50676
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
50648
50677
  if (isGlobalScopeAugmentationDeclaration) {
@@ -50661,16 +50690,9 @@ var ts;
50661
50690
  }
50662
50691
  }
50663
50692
  }
50664
- if (!suggestion) {
50665
- if (nameArg) {
50666
- var lib = getSuggestedLibForNonExistentName(nameArg);
50667
- if (lib) {
50668
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
50669
- }
50670
- else {
50671
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50672
- }
50673
- }
50693
+ // And then fall back to unspecified "not found"
50694
+ if (!suggestion && !suggestedLib && nameArg) {
50695
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50674
50696
  }
50675
50697
  suggestionCount++;
50676
50698
  }
@@ -50678,12 +50700,7 @@ var ts;
50678
50700
  }
50679
50701
  return undefined;
50680
50702
  }
50681
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50682
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
50683
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50684
- // with ESNext+useDefineForClassFields because the scope semantics are different.
50685
- var propertyName = propertyWithInvalidInitializer.name;
50686
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
50703
+ else if (checkAndReportErrorForInvalidInitializer()) {
50687
50704
  return undefined;
50688
50705
  }
50689
50706
  // Perform extra checks only if error reporting was requested
@@ -62550,19 +62567,22 @@ var ts;
62550
62567
  * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
62551
62568
  */
62552
62569
  function isPossiblyReducibleByInstantiation(type) {
62553
- return ts.some(type.types, function (t) {
62554
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
62555
- return getReducedType(uniqueFilled) !== uniqueFilled;
62556
- });
62570
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
62571
+ return getReducedType(uniqueFilled) !== uniqueFilled;
62572
+ }
62573
+ function shouldDeferIndexType(type) {
62574
+ return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
62575
+ isGenericTupleType(type) ||
62576
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
62577
+ type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
62578
+ type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
62557
62579
  }
62558
62580
  function getIndexType(type, stringsOnly, noIndexSignatures) {
62559
62581
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
62560
62582
  type = getReducedType(type);
62561
- return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
62562
- ? getIndexTypeForGenericType(type, stringsOnly)
62563
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62564
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62565
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62583
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62584
+ type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62585
+ type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62566
62586
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
62567
62587
  type === wildcardType ? wildcardType :
62568
62588
  type.flags & 2 /* Unknown */ ? neverType :
@@ -70152,6 +70172,15 @@ var ts;
70152
70172
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
70153
70173
  return key && key + "." + propName;
70154
70174
  }
70175
+ break;
70176
+ case 201 /* ObjectBindingPattern */:
70177
+ case 202 /* ArrayBindingPattern */:
70178
+ case 256 /* FunctionDeclaration */:
70179
+ case 213 /* FunctionExpression */:
70180
+ case 214 /* ArrowFunction */:
70181
+ case 169 /* MethodDeclaration */:
70182
+ // Handle pseudo-references originating in getNarrowedTypeOfSymbol.
70183
+ return getNodeId(node) + "#" + getTypeId(declaredType);
70155
70184
  }
70156
70185
  return undefined;
70157
70186
  }
@@ -132984,6 +133013,26 @@ var ts;
132984
133013
  (function (Completions) {
132985
133014
  var StringCompletions;
132986
133015
  (function (StringCompletions) {
133016
+ var _a;
133017
+ var kindPrecedence = (_a = {},
133018
+ _a["directory" /* directory */] = 0,
133019
+ _a["script" /* scriptElement */] = 1,
133020
+ _a["external module name" /* externalModuleName */] = 2,
133021
+ _a);
133022
+ function createNameAndKindSet() {
133023
+ var map = new ts.Map();
133024
+ function add(value) {
133025
+ var existing = map.get(value.name);
133026
+ if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) {
133027
+ map.set(value.name, value);
133028
+ }
133029
+ }
133030
+ return {
133031
+ add: add,
133032
+ has: map.has.bind(map),
133033
+ values: map.values.bind(map),
133034
+ };
133035
+ }
132987
133036
  function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
132988
133037
  if (ts.isInReferenceComment(sourceFile, position)) {
132989
133038
  var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
@@ -133265,11 +133314,12 @@ var ts;
133265
133314
  }
133266
133315
  function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) {
133267
133316
  var literalValue = ts.normalizeSlashes(node.text);
133317
+ var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
133268
133318
  var scriptPath = sourceFile.path;
133269
133319
  var scriptDirectory = ts.getDirectoryPath(scriptPath);
133270
133320
  return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
133271
133321
  ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
133272
- : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
133322
+ : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker);
133273
133323
  function getIncludeExtensionOption() {
133274
133324
  var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
133275
133325
  return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
@@ -133285,7 +133335,7 @@ var ts;
133285
133335
  return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
133286
133336
  }
133287
133337
  else {
133288
- return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
133338
+ return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values());
133289
133339
  }
133290
133340
  }
133291
133341
  function isEmitResolutionKindUsingNodeModules(compilerOptions) {
@@ -133321,7 +133371,7 @@ var ts;
133321
133371
  var basePath = compilerOptions.project || host.getCurrentDirectory();
133322
133372
  var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
133323
133373
  var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase);
133324
- return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); });
133374
+ return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); });
133325
133375
  }
133326
133376
  var IncludeExtensionsOption;
133327
133377
  (function (IncludeExtensionsOption) {
@@ -133332,10 +133382,9 @@ var ts;
133332
133382
  /**
133333
133383
  * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename.
133334
133384
  */
133335
- function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) {
133336
- var _b;
133337
- var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption;
133338
- if (result === void 0) { result = []; }
133385
+ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) {
133386
+ var _a;
133387
+ if (result === void 0) { result = createNameAndKindSet(); }
133339
133388
  if (fragment === undefined) {
133340
133389
  fragment = "";
133341
133390
  }
@@ -133359,11 +133408,11 @@ var ts;
133359
133408
  var packageJson = ts.readJson(packageJsonPath, host);
133360
133409
  var typesVersions = packageJson.typesVersions;
133361
133410
  if (typeof typesVersions === "object") {
133362
- var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths;
133411
+ var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
133363
133412
  if (versionPaths) {
133364
133413
  var packageDirectory = ts.getDirectoryPath(packageJsonPath);
133365
133414
  var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length);
133366
- if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) {
133415
+ if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) {
133367
133416
  // A true result means one of the `versionPaths` was matched, which will block relative resolution
133368
133417
  // to files and folders from here. All reachable paths given the pattern match are already added.
133369
133418
  return result;
@@ -133375,39 +133424,17 @@ var ts;
133375
133424
  if (!ts.tryDirectoryExists(host, baseDirectory))
133376
133425
  return result;
133377
133426
  // Enumerate the available files if possible
133378
- var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
133427
+ var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]);
133379
133428
  if (files) {
133380
- /**
133381
- * Multiple file entries might map to the same truncated name once we remove extensions
133382
- * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg:
133383
- *
133384
- * both foo.ts and foo.tsx become foo
133385
- */
133386
- var foundFiles = new ts.Map(); // maps file to its extension
133387
133429
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
133388
133430
  var filePath = files_1[_i];
133389
133431
  filePath = ts.normalizePath(filePath);
133390
133432
  if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) {
133391
133433
  continue;
133392
133434
  }
133393
- var foundFileName = void 0;
133394
- var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
133395
- if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
133396
- foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
133397
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
133398
- }
133399
- else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
133400
- foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
133401
- foundFiles.set(foundFileName, outputExtension);
133402
- }
133403
- else {
133404
- foundFileName = ts.getBaseFileName(filePath);
133405
- foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
133406
- }
133435
+ var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension;
133436
+ result.add(nameAndKind(name, "script" /* scriptElement */, extension));
133407
133437
  }
133408
- foundFiles.forEach(function (ext, foundFile) {
133409
- result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext));
133410
- });
133411
133438
  }
133412
133439
  // If possible, get folder completion as well
133413
133440
  var directories = ts.tryGetDirectories(host, baseDirectory);
@@ -133416,27 +133443,52 @@ var ts;
133416
133443
  var directory = directories_1[_c];
133417
133444
  var directoryName = ts.getBaseFileName(ts.normalizePath(directory));
133418
133445
  if (directoryName !== "@types") {
133419
- result.push(directoryResult(directoryName));
133446
+ result.add(directoryResult(directoryName));
133420
133447
  }
133421
133448
  }
133422
133449
  }
133423
133450
  return result;
133424
133451
  }
133452
+ function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) {
133453
+ var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions);
133454
+ if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
133455
+ return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) };
133456
+ }
133457
+ else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
133458
+ return { name: ts.changeExtension(name, outputExtension), extension: outputExtension };
133459
+ }
133460
+ else {
133461
+ return { name: name, extension: ts.tryGetExtensionFromPath(name) };
133462
+ }
133463
+ }
133425
133464
  /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
133426
- function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) {
133427
- var _a;
133465
+ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) {
133466
+ var getPatternsForKey = function (key) { return paths[key]; };
133467
+ var comparePaths = function (a, b) {
133468
+ var patternA = ts.tryParsePattern(a);
133469
+ var patternB = ts.tryParsePattern(b);
133470
+ var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length;
133471
+ var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
133472
+ return ts.compareValues(lengthB, lengthA);
133473
+ };
133474
+ return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths);
133475
+ }
133476
+ /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */
133477
+ function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) {
133428
133478
  var pathResults = [];
133429
- var matchedPathPrefixLength = -1;
133430
- for (var path in paths) {
133431
- if (!ts.hasProperty(paths, path))
133479
+ var matchedPath;
133480
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
133481
+ var key = keys_1[_i];
133482
+ if (key === ".")
133432
133483
  continue;
133433
- var patterns = paths[path];
133484
+ var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./"
133485
+ var patterns = getPatternsForKey(key);
133434
133486
  if (patterns) {
133435
- var pathPattern = ts.tryParsePattern(path);
133487
+ var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash);
133436
133488
  if (!pathPattern)
133437
133489
  continue;
133438
133490
  var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment);
133439
- var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength);
133491
+ var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* LessThan */);
133440
133492
  if (isLongestMatch) {
133441
133493
  // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g.
133442
133494
  // for `import {} from "some-package/|"` with a typesVersions:
@@ -133449,13 +133501,13 @@ var ts;
133449
133501
  // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both
133450
133502
  // ./dist/foo and ./foo, when only the latter will actually be resolvable.
133451
133503
  // See pathCompletionsTypesVersionsWildcard6.ts.
133452
- matchedPathPrefixLength = pathPattern.prefix.length;
133504
+ matchedPath = key;
133453
133505
  pathResults = pathResults.filter(function (r) { return !r.matchedPattern; });
133454
133506
  }
133455
- if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) {
133507
+ if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* GreaterThan */) {
133456
133508
  pathResults.push({
133457
133509
  matchedPattern: isMatch,
133458
- results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host)
133510
+ results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host)
133459
133511
  .map(function (_a) {
133460
133512
  var name = _a.name, kind = _a.kind, extension = _a.extension;
133461
133513
  return nameAndKind(name, kind, extension);
@@ -133464,10 +133516,8 @@ var ts;
133464
133516
  }
133465
133517
  }
133466
133518
  }
133467
- var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
133468
- var equateResults = function (a, b) { return equatePaths(a.name, b.name); };
133469
- pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); });
133470
- return matchedPathPrefixLength > -1;
133519
+ pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); });
133520
+ return matchedPath !== undefined;
133471
133521
  }
133472
133522
  /**
133473
133523
  * Check all of the declared modules and those in node modules. Possible sources of modules:
@@ -133476,22 +133526,22 @@ var ts;
133476
133526
  * Modules from node_modules (i.e. those listed in package.json)
133477
133527
  * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions
133478
133528
  */
133479
- function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) {
133529
+ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) {
133480
133530
  var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths;
133481
- var result = [];
133482
- var extensionOptions = getExtensionOptions(compilerOptions);
133531
+ var result = createNameAndKindSet();
133532
+ var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption);
133483
133533
  if (baseUrl) {
133484
133534
  var projectDir = compilerOptions.project || host.getCurrentDirectory();
133485
133535
  var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl));
133486
133536
  getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result);
133487
133537
  if (paths) {
133488
- addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host);
133538
+ addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths);
133489
133539
  }
133490
133540
  }
133491
133541
  var fragmentDirectory = getFragmentDirectory(fragment);
133492
133542
  for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) {
133493
133543
  var ambientName = _a[_i];
133494
- result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133544
+ result.add(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133495
133545
  }
133496
133546
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
133497
133547
  if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
@@ -133499,15 +133549,13 @@ var ts;
133499
133549
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
133500
133550
  var foundGlobal = false;
133501
133551
  if (fragmentDirectory === undefined) {
133502
- var _loop_3 = function (moduleName) {
133503
- if (!result.some(function (entry) { return entry.name === moduleName; })) {
133504
- foundGlobal = true;
133505
- result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133506
- }
133507
- };
133508
133552
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
133509
133553
  var moduleName = _c[_b];
133510
- _loop_3(moduleName);
133554
+ var moduleResult = nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined);
133555
+ if (!result.has(moduleResult.name)) {
133556
+ foundGlobal = true;
133557
+ result.add(moduleResult);
133558
+ }
133511
133559
  }
133512
133560
  }
133513
133561
  if (!foundGlobal) {
@@ -133533,39 +133581,19 @@ var ts;
133533
133581
  }
133534
133582
  packagePath = ts.combinePaths(packagePath, subName);
133535
133583
  }
133536
- var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
133584
+ var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
133585
+ var packageFile = ts.combinePaths(packageDirectory, "package.json");
133537
133586
  if (ts.tryFileExists(host, packageFile)) {
133538
133587
  var packageJson = ts.readJson(packageFile, host);
133539
- var exports = packageJson.exports;
133540
- if (exports) {
133541
- if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
133588
+ var exports_1 = packageJson.exports;
133589
+ if (exports_1) {
133590
+ if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
133542
133591
  return; // null exports or entrypoint only, no sub-modules available
133543
133592
  }
133544
- var keys = ts.getOwnKeys(exports);
133545
- var fragmentSubpath_1 = components.join("/");
133546
- var processedKeys = ts.mapDefined(keys, function (k) {
133547
- if (k === ".")
133548
- return undefined;
133549
- if (!ts.startsWith(k, "./"))
133550
- return undefined;
133551
- var subpath = k.substring(2);
133552
- if (!ts.startsWith(subpath, fragmentSubpath_1))
133553
- return undefined;
133554
- // subpath is a valid export (barring conditions, which we don't currently check here)
133555
- if (!ts.stringContains(subpath, "*")) {
133556
- return subpath;
133557
- }
133558
- // pattern export - only return everything up to the `*`, so the user can autocomplete, then
133559
- // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
133560
- // but conditions will make that somewhat awkward, as each condition may have a different set of possible
133561
- // options for the `*`.
133562
- return subpath.slice(0, subpath.indexOf("*"));
133563
- });
133564
- ts.forEach(processedKeys, function (k) {
133565
- if (k) {
133566
- result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
133567
- }
133568
- });
133593
+ var keys = ts.getOwnKeys(exports_1);
133594
+ var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : "");
133595
+ var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
133596
+ addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys);
133569
133597
  return;
133570
133598
  }
133571
133599
  }
@@ -133575,31 +133603,44 @@ var ts;
133575
133603
  ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
133576
133604
  }
133577
133605
  }
133578
- return result;
133606
+ return ts.arrayFrom(result.values());
133607
+ }
133608
+ function getPatternFromFirstMatchingCondition(target, conditions) {
133609
+ if (typeof target === "string") {
133610
+ return target;
133611
+ }
133612
+ if (target && typeof target === "object" && !ts.isArray(target)) {
133613
+ for (var condition in target) {
133614
+ if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) {
133615
+ var pattern = target[condition];
133616
+ return getPatternFromFirstMatchingCondition(pattern, conditions);
133617
+ }
133618
+ }
133619
+ }
133579
133620
  }
133580
133621
  function getFragmentDirectory(fragment) {
133581
133622
  return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined;
133582
133623
  }
133583
- function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) {
133624
+ function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) {
133584
133625
  if (!ts.endsWith(path, "*")) {
133585
133626
  // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion.
133586
- return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray;
133627
+ return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* scriptElement */) : ts.emptyArray;
133587
133628
  }
133588
133629
  var pathPrefix = path.slice(0, path.length - 1);
133589
133630
  var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix);
133590
133631
  if (remainingFragment === undefined) {
133591
133632
  var starIsFullPathComponent = path[path.length - 2] === "/";
133592
- 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) {
133633
+ 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) {
133593
133634
  var name = _a.name, rest = __rest(_a, ["name"]);
133594
133635
  return (__assign({ name: pathPrefix + name }, rest));
133595
133636
  }); });
133596
133637
  }
133597
- return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); });
133598
- function justPathMappingName(name) {
133599
- return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray;
133638
+ return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); });
133639
+ function justPathMappingName(name, kind) {
133640
+ return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray;
133600
133641
  }
133601
133642
  }
133602
- function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) {
133643
+ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) {
133603
133644
  if (!host.readDirectory) {
133604
133645
  return undefined;
133605
133646
  }
@@ -133618,21 +133659,33 @@ var ts;
133618
133659
  var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
133619
133660
  var normalizedSuffix = ts.normalizePath(parsed.suffix);
133620
133661
  // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
133621
- var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory));
133662
+ var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory));
133622
133663
  var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
133623
- // If we have a suffix, then we need to read the directory all the way down. We could create a glob
133624
- // that encodes the suffix, but we would have to escape the character "?" which readDirectory
133625
- // doesn't support. For now, this is safer but slower
133626
- var includeGlob = normalizedSuffix ? "**/*" : "./*";
133627
- var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133628
- var extension = ts.tryGetExtensionFromPath(match);
133629
- var name = trimPrefixAndSuffix(match);
133630
- return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension);
133631
- });
133632
- var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) {
133633
- var name = trimPrefixAndSuffix(dir);
133634
- return name === undefined ? undefined : directoryResult(name);
133664
+ // If we have a suffix, then we read the directory all the way down to avoid returning completions for
133665
+ // directories that don't contain files that would match the suffix. A previous comment here was concerned
133666
+ // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally,
133667
+ // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not
133668
+ // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?`
133669
+ // interpreted as "any character" can only return *too many* results as compared to the literal
133670
+ // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always
133671
+ // done.
133672
+ var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*";
133673
+ var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) {
133674
+ var trimmedWithPattern = trimPrefixAndSuffix(match);
133675
+ if (trimmedWithPattern) {
133676
+ if (containsSlash(trimmedWithPattern)) {
133677
+ return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
133678
+ }
133679
+ var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension;
133680
+ return nameAndKind(name, "script" /* scriptElement */, extension);
133681
+ }
133635
133682
  });
133683
+ // If we had a suffix, we already recursively searched for all possible files that could match
133684
+ // it and returned the directories leading to those files. Otherwise, assume any directory could
133685
+ // have something valid to import.
133686
+ var directories = normalizedSuffix
133687
+ ? ts.emptyArray
133688
+ : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); });
133636
133689
  return __spreadArray(__spreadArray([], matches, true), directories, true);
133637
133690
  function trimPrefixAndSuffix(path) {
133638
133691
  var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix);
@@ -133675,10 +133728,10 @@ var ts;
133675
133728
  var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path)
133676
133729
  : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions))
133677
133730
  : ts.Debug.fail();
133678
- return addReplacementSpans(toComplete, range.pos + prefix.length, names);
133731
+ return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values()));
133679
133732
  }
133680
133733
  function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) {
133681
- if (result === void 0) { result = []; }
133734
+ if (result === void 0) { result = createNameAndKindSet(); }
133682
133735
  // Check for typings specified in compiler options
133683
133736
  var seen = new ts.Map();
133684
133737
  var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray;
@@ -133703,7 +133756,7 @@ var ts;
133703
133756
  continue;
133704
133757
  if (fragmentDirectory === undefined) {
133705
133758
  if (!seen.has(packageName)) {
133706
- result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133759
+ result.add(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined));
133707
133760
  seen.set(packageName, true);
133708
133761
  }
133709
133762
  }
@@ -139304,7 +139357,7 @@ var ts;
139304
139357
  result = references;
139305
139358
  continue;
139306
139359
  }
139307
- var _loop_4 = function (entry) {
139360
+ var _loop_3 = function (entry) {
139308
139361
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
139309
139362
  result.push(entry);
139310
139363
  return "continue";
@@ -139336,7 +139389,7 @@ var ts;
139336
139389
  };
139337
139390
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
139338
139391
  var entry = references_2[_b];
139339
- _loop_4(entry);
139392
+ _loop_3(entry);
139340
139393
  }
139341
139394
  }
139342
139395
  return result;
@@ -140917,8 +140970,8 @@ var ts;
140917
140970
  var declarations;
140918
140971
  if (symbol && symbol.declarations) {
140919
140972
  var indices = ts.indicesOf(symbol.declarations);
140920
- var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140921
- indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; });
140973
+ var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); });
140974
+ indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; });
140922
140975
  var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; });
140923
140976
  var lastDecl = void 0;
140924
140977
  for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) {
@@ -141366,7 +141419,7 @@ var ts;
141366
141419
  }
141367
141420
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
141368
141421
  var allFiles = program.getSourceFiles();
141369
- var _loop_5 = function (sourceFile) {
141422
+ var _loop_4 = function (sourceFile) {
141370
141423
  var newFromOld = oldToNew(sourceFile.fileName);
141371
141424
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
141372
141425
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -141398,7 +141451,7 @@ var ts;
141398
141451
  };
141399
141452
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
141400
141453
  var sourceFile = allFiles_1[_i];
141401
- _loop_5(sourceFile);
141454
+ _loop_4(sourceFile);
141402
141455
  }
141403
141456
  }
141404
141457
  function combineNormal(pathA, pathB) {
@@ -142422,7 +142475,7 @@ var ts;
142422
142475
  if (!patternMatcher)
142423
142476
  return ts.emptyArray;
142424
142477
  var rawItems = [];
142425
- var _loop_6 = function (sourceFile) {
142478
+ var _loop_5 = function (sourceFile) {
142426
142479
  cancellationToken.throwIfCancellationRequested();
142427
142480
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
142428
142481
  return "continue";
@@ -142434,7 +142487,7 @@ var ts;
142434
142487
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
142435
142488
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
142436
142489
  var sourceFile = sourceFiles_4[_i];
142437
- _loop_6(sourceFile);
142490
+ _loop_5(sourceFile);
142438
142491
  }
142439
142492
  rawItems.sort(compareNavigateToItems);
142440
142493
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -144497,13 +144550,13 @@ var ts;
144497
144550
  // Assumes 'value' is already lowercase.
144498
144551
  function indexOfIgnoringCase(str, value) {
144499
144552
  var n = str.length - value.length;
144500
- var _loop_7 = function (start) {
144553
+ var _loop_6 = function (start) {
144501
144554
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
144502
144555
  return { value: start };
144503
144556
  }
144504
144557
  };
144505
144558
  for (var start = 0; start <= n; start++) {
144506
- var state_3 = _loop_7(start);
144559
+ var state_3 = _loop_6(start);
144507
144560
  if (typeof state_3 === "object")
144508
144561
  return state_3.value;
144509
144562
  }
@@ -145970,7 +146023,7 @@ var ts;
145970
146023
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
145971
146024
  }
145972
146025
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
145973
- var _loop_8 = function (n) {
146026
+ var _loop_7 = function (n) {
145974
146027
  // If the node is not a subspan of its parent, this is a big problem.
145975
146028
  // There have been crashes that might be caused by this violation.
145976
146029
  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); });
@@ -145980,7 +146033,7 @@ var ts;
145980
146033
  }
145981
146034
  };
145982
146035
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
145983
- var state_4 = _loop_8(n);
146036
+ var state_4 = _loop_7(n);
145984
146037
  if (typeof state_4 === "object")
145985
146038
  return state_4.value;
145986
146039
  }
@@ -147593,7 +147646,7 @@ var ts;
147593
147646
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
147594
147647
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
147595
147648
  options = ts.cloneCompilerOptions(options);
147596
- var _loop_9 = function (opt) {
147649
+ var _loop_8 = function (opt) {
147597
147650
  if (!ts.hasProperty(options, opt.name)) {
147598
147651
  return "continue";
147599
147652
  }
@@ -147612,7 +147665,7 @@ var ts;
147612
147665
  };
147613
147666
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
147614
147667
  var opt = commandLineOptionsStringToEnum_1[_i];
147615
- _loop_9(opt);
147668
+ _loop_8(opt);
147616
147669
  }
147617
147670
  return options;
147618
147671
  }
@@ -151377,7 +151430,7 @@ var ts;
151377
151430
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
151378
151431
  var _this = this;
151379
151432
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
151380
- var _loop_10 = function (sourceFile, node) {
151433
+ var _loop_9 = function (sourceFile, node) {
151381
151434
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
151382
151435
  if (ts.isArray(node)) {
151383
151436
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -151390,7 +151443,7 @@ var ts;
151390
151443
  var this_1 = this;
151391
151444
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
151392
151445
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
151393
- _loop_10(sourceFile, node);
151446
+ _loop_9(sourceFile, node);
151394
151447
  }
151395
151448
  deletedNodesInLists.forEach(function (node) {
151396
151449
  var sourceFile = node.getSourceFile();
@@ -151478,14 +151531,14 @@ var ts;
151478
151531
  // order changes by start position
151479
151532
  // 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.
151480
151533
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
151481
- var _loop_11 = function (i) {
151534
+ var _loop_10 = function (i) {
151482
151535
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
151483
151536
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
151484
151537
  });
151485
151538
  };
151486
151539
  // verify that change intervals do not overlap, except possibly at end points.
151487
151540
  for (var i = 0; i < normalized.length - 1; i++) {
151488
- _loop_11(i);
151541
+ _loop_10(i);
151489
151542
  }
151490
151543
  var textChanges = ts.mapDefined(normalized, function (c) {
151491
151544
  var span = ts.createTextSpanFromRange(c.range);
@@ -152393,7 +152446,7 @@ var ts;
152393
152446
  }
152394
152447
  var isCompleteFix = identifiers.isCompleteFix;
152395
152448
  var initializers;
152396
- var _loop_12 = function (identifier) {
152449
+ var _loop_11 = function (identifier) {
152397
152450
  var symbol = checker.getSymbolAtLocation(identifier);
152398
152451
  if (!symbol) {
152399
152452
  return "continue";
@@ -152426,7 +152479,7 @@ var ts;
152426
152479
  };
152427
152480
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
152428
152481
  var identifier = _a[_i];
152429
- _loop_12(identifier);
152482
+ _loop_11(identifier);
152430
152483
  }
152431
152484
  return initializers && {
152432
152485
  initializers: initializers,
@@ -153311,7 +153364,7 @@ var ts;
153311
153364
  }
153312
153365
  var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos);
153313
153366
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " });
153314
- var _loop_13 = function (returnStatement) {
153367
+ var _loop_12 = function (returnStatement) {
153315
153368
  ts.forEachChild(returnStatement, function visit(node) {
153316
153369
  if (ts.isCallExpression(node)) {
153317
153370
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -153333,7 +153386,7 @@ var ts;
153333
153386
  };
153334
153387
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
153335
153388
  var returnStatement = returnStatements_1[_i];
153336
- var state_5 = _loop_13(returnStatement);
153389
+ var state_5 = _loop_12(returnStatement);
153337
153390
  if (typeof state_5 === "object")
153338
153391
  return state_5.value;
153339
153392
  }
@@ -156668,7 +156721,7 @@ var ts;
156668
156721
  });
156669
156722
  typeDeclToMembers.forEach(function (infos, declaration) {
156670
156723
  var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
156671
- var _loop_14 = function (info) {
156724
+ var _loop_13 = function (info) {
156672
156725
  // If some superclass added this property, don't add it again.
156673
156726
  if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
156674
156727
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -156695,7 +156748,7 @@ var ts;
156695
156748
  };
156696
156749
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
156697
156750
  var info = infos_1[_i];
156698
- _loop_14(info);
156751
+ _loop_13(info);
156699
156752
  }
156700
156753
  });
156701
156754
  }));
@@ -159469,7 +159522,7 @@ var ts;
159469
159522
  function getSignatureFromCalls(calls) {
159470
159523
  var parameters = [];
159471
159524
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
159472
- var _loop_15 = function (i) {
159525
+ var _loop_14 = function (i) {
159473
159526
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
159474
159527
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
159475
159528
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -159478,7 +159531,7 @@ var ts;
159478
159531
  parameters.push(symbol);
159479
159532
  };
159480
159533
  for (var i = 0; i < length; i++) {
159481
- _loop_15(i);
159534
+ _loop_14(i);
159482
159535
  }
159483
159536
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
159484
159537
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -161454,7 +161507,7 @@ var ts;
161454
161507
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
161455
161508
  // 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 }`.
161456
161509
  var neededNamedImports = new ts.Set();
161457
- var _loop_16 = function (element) {
161510
+ var _loop_15 = function (element) {
161458
161511
  var propertyName = (element.propertyName || element.name).text;
161459
161512
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
161460
161513
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -161471,7 +161524,7 @@ var ts;
161471
161524
  };
161472
161525
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
161473
161526
  var element = _a[_i];
161474
- _loop_16(element);
161527
+ _loop_15(element);
161475
161528
  }
161476
161529
  changes.replaceNode(sourceFile, toConvert, shouldUseDefault
161477
161530
  ? ts.factory.createIdentifier(namespaceImportName)
@@ -163362,7 +163415,7 @@ var ts;
163362
163415
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
163363
163416
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
163364
163417
  }
163365
- var _loop_17 = function (i) {
163418
+ var _loop_16 = function (i) {
163366
163419
  var scopeUsages = usagesPerScope[i];
163367
163420
  // Special case: in the innermost scope, all usages are available.
163368
163421
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -163405,7 +163458,7 @@ var ts;
163405
163458
  }
163406
163459
  };
163407
163460
  for (var i = 0; i < scopes.length; i++) {
163408
- _loop_17(i);
163461
+ _loop_16(i);
163409
163462
  }
163410
163463
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
163411
163464
  function isInGenericContext(node) {
@@ -164106,10 +164159,10 @@ var ts;
164106
164159
  }
164107
164160
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
164108
164161
  var checker = program.getTypeChecker();
164109
- var _loop_18 = function (sourceFile) {
164162
+ var _loop_17 = function (sourceFile) {
164110
164163
  if (sourceFile === oldFile)
164111
164164
  return "continue";
164112
- var _loop_19 = function (statement) {
164165
+ var _loop_18 = function (statement) {
164113
164166
  forEachImportInStatement(statement, function (importNode) {
164114
164167
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
164115
164168
  return;
@@ -164131,12 +164184,12 @@ var ts;
164131
164184
  };
164132
164185
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
164133
164186
  var statement = _c[_b];
164134
- _loop_19(statement);
164187
+ _loop_18(statement);
164135
164188
  }
164136
164189
  };
164137
164190
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
164138
164191
  var sourceFile = _a[_i];
164139
- _loop_18(sourceFile);
164192
+ _loop_17(sourceFile);
164140
164193
  }
164141
164194
  }
164142
164195
  function getNamespaceLikeImport(node) {
@@ -165499,7 +165552,7 @@ var ts;
165499
165552
  var templateSpans = [];
165500
165553
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
165501
165554
  copyCommentFromStringLiterals(headIndexes, templateHead);
165502
- var _loop_20 = function (i) {
165555
+ var _loop_19 = function (i) {
165503
165556
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
165504
165557
  copyOperatorComments(i, currentNode);
165505
165558
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -165528,7 +165581,7 @@ var ts;
165528
165581
  };
165529
165582
  var out_i_1;
165530
165583
  for (var i = begin; i < nodes.length; i++) {
165531
- _loop_20(i);
165584
+ _loop_19(i);
165532
165585
  i = out_i_1;
165533
165586
  }
165534
165587
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -166374,7 +166427,7 @@ var ts;
166374
166427
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
166375
166428
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
166376
166429
  var seenSymbols_1 = new ts.Set();
166377
- var _loop_21 = function (declaration) {
166430
+ var _loop_20 = function (declaration) {
166378
166431
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
166379
166432
  var _a;
166380
166433
  if (!seenSymbols_1.has(symbol)) {
@@ -166391,7 +166444,7 @@ var ts;
166391
166444
  };
166392
166445
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
166393
166446
  var declaration = declarations_7[_i];
166394
- _loop_21(declaration);
166447
+ _loop_20(declaration);
166395
166448
  }
166396
166449
  }
166397
166450
  return tags;
@@ -166402,7 +166455,7 @@ var ts;
166402
166455
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
166403
166456
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
166404
166457
  var seenSymbols_2 = new ts.Set();
166405
- var _loop_22 = function (declaration) {
166458
+ var _loop_21 = function (declaration) {
166406
166459
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
166407
166460
  if (!seenSymbols_2.has(symbol)) {
166408
166461
  seenSymbols_2.add(symbol);
@@ -166418,7 +166471,7 @@ var ts;
166418
166471
  };
166419
166472
  for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
166420
166473
  var declaration = declarations_8[_i];
166421
- _loop_22(declaration);
166474
+ _loop_21(declaration);
166422
166475
  }
166423
166476
  }
166424
166477
  return doc;