typescript 4.8.0-dev.20220616 → 4.8.0-dev.20220617

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.20220616";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -9866,6 +9866,8 @@ var ts;
9866
9866
  Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
9867
9867
  A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
9868
9868
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9869
+ You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
9870
+ You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
9869
9871
  Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
9870
9872
  Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
9871
9873
  JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
@@ -49104,9 +49106,9 @@ var ts;
49104
49106
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
49105
49107
  },
49106
49108
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
49107
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
49109
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
49108
49110
  var node = ts.getParseTreeNode(nodeIn);
49109
- return node && tryGetThisTypeAt(node, includeGlobalThis);
49111
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
49110
49112
  },
49111
49113
  getTypeArgumentConstraint: function (nodeIn) {
49112
49114
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -59554,7 +59556,7 @@ var ts;
59554
59556
  }
59555
59557
  if (t.flags & 268435456 /* StringMapping */) {
59556
59558
  var constraint = getBaseConstraint(t.type);
59557
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59559
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59558
59560
  }
59559
59561
  if (t.flags & 8388608 /* IndexedAccess */) {
59560
59562
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62524,9 +62526,12 @@ var ts;
62524
62526
  }
62525
62527
  function getStringMappingType(symbol, type) {
62526
62528
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62527
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62528
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62529
- type;
62529
+ // Mapping<Mapping<T>> === Mapping<T>
62530
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62531
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62532
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62533
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62534
+ type;
62530
62535
  }
62531
62536
  function applyStringMapping(symbol, str) {
62532
62537
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62537,6 +62542,15 @@ var ts;
62537
62542
  }
62538
62543
  return str;
62539
62544
  }
62545
+ function applyTemplateStringMapping(symbol, texts, types) {
62546
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62547
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62548
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62549
+ case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62550
+ case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62551
+ }
62552
+ return [texts, types];
62553
+ }
62540
62554
  function getStringMappingTypeForGenericType(symbol, type) {
62541
62555
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62542
62556
  var result = stringMappingTypes.get(id);
@@ -62778,7 +62792,7 @@ var ts;
62778
62792
  accessNode;
62779
62793
  }
62780
62794
  function isPatternLiteralPlaceholderType(type) {
62781
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62795
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62782
62796
  }
62783
62797
  function isPatternLiteralType(type) {
62784
62798
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -66490,6 +66504,13 @@ var ts;
66490
66504
  return -1 /* True */;
66491
66505
  }
66492
66506
  }
66507
+ else if (target.flags & 268435456 /* StringMapping */) {
66508
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66509
+ if (isMemberOfStringMapping(source, target)) {
66510
+ return -1 /* True */;
66511
+ }
66512
+ }
66513
+ }
66493
66514
  if (sourceFlags & 8650752 /* TypeVariable */) {
66494
66515
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66495
66516
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66533,7 +66554,10 @@ var ts;
66533
66554
  }
66534
66555
  }
66535
66556
  else if (sourceFlags & 268435456 /* StringMapping */) {
66536
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66557
+ if (targetFlags & 268435456 /* StringMapping */) {
66558
+ if (source.symbol !== target.symbol) {
66559
+ return 0 /* False */;
66560
+ }
66537
66561
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66538
66562
  resetErrorInfo(saveErrorInfo);
66539
66563
  return result;
@@ -67458,7 +67482,7 @@ var ts;
67458
67482
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67459
67483
  }
67460
67484
  }
67461
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67485
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67462
67486
  }
67463
67487
  function getExactOptionalUnassignableProperties(source, target) {
67464
67488
  if (isTupleType(source) && isTupleType(target))
@@ -68929,6 +68953,31 @@ var ts;
68929
68953
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68930
68954
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68931
68955
  }
68956
+ function isMemberOfStringMapping(source, target) {
68957
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68958
+ return true;
68959
+ }
68960
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68961
+ return isTypeAssignableTo(source, target);
68962
+ }
68963
+ if (target.flags & 268435456 /* StringMapping */) {
68964
+ // We need to see whether applying the same mappings of the target
68965
+ // onto the source would produce an identical type *and* that
68966
+ // it's compatible with the inner-most non-string-mapped type.
68967
+ //
68968
+ // The intuition here is that if same mappings don't affect the source at all,
68969
+ // and the source is compatible with the unmapped target, then they must
68970
+ // still reside in the same domain.
68971
+ var mappingStack = [];
68972
+ while (target.flags & 268435456 /* StringMapping */) {
68973
+ mappingStack.unshift(target.symbol);
68974
+ target = target.type;
68975
+ }
68976
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
68977
+ return mappedSource === source && isMemberOfStringMapping(source, target);
68978
+ }
68979
+ return false;
68980
+ }
68932
68981
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68933
68982
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68934
68983
  return true;
@@ -68937,7 +68986,8 @@ var ts;
68937
68986
  var value = source.value;
68938
68987
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68939
68988
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68940
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68989
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
68990
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68941
68991
  }
68942
68992
  if (source.flags & 134217728 /* TemplateLiteral */) {
68943
68993
  var texts = source.texts;
@@ -135395,7 +135445,7 @@ var ts;
135395
135445
  }
135396
135446
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
135397
135447
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
135398
- var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
135448
+ var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
135399
135449
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
135400
135450
  for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
135401
135451
  var symbol = _a[_i];
@@ -144733,10 +144783,10 @@ var ts;
144733
144783
  (function (ts) {
144734
144784
  var Rename;
144735
144785
  (function (Rename) {
144736
- function getRenameInfo(program, sourceFile, position, options) {
144786
+ function getRenameInfo(program, sourceFile, position, preferences) {
144737
144787
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
144738
144788
  if (nodeIsEligibleForRename(node)) {
144739
- var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options);
144789
+ var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
144740
144790
  if (renameInfo) {
144741
144791
  return renameInfo;
144742
144792
  }
@@ -144744,7 +144794,7 @@ var ts;
144744
144794
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
144745
144795
  }
144746
144796
  Rename.getRenameInfo = getRenameInfo;
144747
- function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) {
144797
+ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
144748
144798
  var symbol = typeChecker.getSymbolAtLocation(node);
144749
144799
  if (!symbol) {
144750
144800
  if (ts.isStringLiteralLike(node)) {
@@ -144772,7 +144822,12 @@ var ts;
144772
144822
  return undefined;
144773
144823
  }
144774
144824
  if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
144775
- return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144825
+ return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144826
+ }
144827
+ // Disallow rename for elements that would rename across `*/node_modules/*` packages.
144828
+ var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
144829
+ if (wouldRenameNodeModules) {
144830
+ return getRenameInfoError(wouldRenameNodeModules);
144776
144831
  }
144777
144832
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
144778
144833
  var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
@@ -144786,6 +144841,49 @@ var ts;
144786
144841
  var sourceFile = declaration.getSourceFile();
144787
144842
  return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
144788
144843
  }
144844
+ function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
144845
+ if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
144846
+ var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
144847
+ if (importSpecifier && !importSpecifier.propertyName) {
144848
+ symbol = checker.getAliasedSymbol(symbol);
144849
+ }
144850
+ }
144851
+ var declarations = symbol.declarations;
144852
+ if (!declarations) {
144853
+ return undefined;
144854
+ }
144855
+ var originalPackage = getPackagePathComponents(originalFile.path);
144856
+ if (originalPackage === undefined) { // original source file is not in node_modules
144857
+ if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
144858
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
144859
+ }
144860
+ else {
144861
+ return undefined;
144862
+ }
144863
+ }
144864
+ // original source file is in node_modules
144865
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
144866
+ var declaration = declarations_4[_i];
144867
+ var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
144868
+ if (declPackage) {
144869
+ var length_2 = Math.min(originalPackage.length, declPackage.length);
144870
+ for (var i = 0; i <= length_2; i++) {
144871
+ if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
144872
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
144873
+ }
144874
+ }
144875
+ }
144876
+ }
144877
+ return undefined;
144878
+ }
144879
+ function getPackagePathComponents(filePath) {
144880
+ var components = ts.getPathComponents(filePath);
144881
+ var nodeModulesIdx = components.lastIndexOf("node_modules");
144882
+ if (nodeModulesIdx === -1) {
144883
+ return undefined;
144884
+ }
144885
+ return components.slice(0, nodeModulesIdx + 2);
144886
+ }
144789
144887
  function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
144790
144888
  if (!ts.isExternalModuleNameRelative(node.text)) {
144791
144889
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
@@ -161825,11 +161923,11 @@ var ts;
161825
161923
  }
161826
161924
  }
161827
161925
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
161828
- var declarations_5 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161926
+ var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161829
161927
  var numInitializers = 0;
161830
161928
  var lastInitializer = void 0;
161831
- for (var _i = 0, declarations_4 = declarations_5; _i < declarations_4.length; _i++) {
161832
- var declaration = declarations_4[_i];
161929
+ for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
161930
+ var declaration = declarations_5[_i];
161833
161931
  if (declaration.initializer) {
161834
161932
  numInitializers++;
161835
161933
  lastInitializer = declaration.initializer;
@@ -165966,8 +166064,8 @@ var ts;
165966
166064
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
165967
166065
  }
165968
166066
  };
165969
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
165970
- var declaration = declarations_6[_i];
166067
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
166068
+ var declaration = declarations_7[_i];
165971
166069
  _loop_21(declaration);
165972
166070
  }
165973
166071
  }
@@ -165993,8 +166091,8 @@ var ts;
165993
166091
  if (inheritedDocs)
165994
166092
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
165995
166093
  };
165996
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165997
- var declaration = declarations_7[_i];
166094
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
166095
+ var declaration = declarations_8[_i];
165998
166096
  _loop_22(declaration);
165999
166097
  }
166000
166098
  }
@@ -167571,9 +167669,9 @@ var ts;
167571
167669
  return ts.stringContains(path, "/node_modules/");
167572
167670
  }
167573
167671
  }
167574
- function getRenameInfo(fileName, position, options) {
167672
+ function getRenameInfo(fileName, position, preferences) {
167575
167673
  synchronizeHostData();
167576
- return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options);
167674
+ return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
167577
167675
  }
167578
167676
  function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
167579
167677
  var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
@@ -168939,9 +169037,9 @@ var ts;
168939
169037
  var _this = this;
168940
169038
  return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
168941
169039
  };
168942
- LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) {
169040
+ LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
168943
169041
  var _this = this;
168944
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); });
169042
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
168945
169043
  };
168946
169044
  LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
168947
169045
  var _this = this;
@@ -176692,7 +176790,7 @@ var ts;
176692
176790
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
176693
176791
  }
176694
176792
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
176695
- var _a;
176793
+ var _a, _b;
176696
176794
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
176697
176795
  /*isForRename*/ false, function (project, position) {
176698
176796
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -176712,7 +176810,7 @@ var ts;
176712
176810
  // have started the other project searches from related symbols. Propagate the
176713
176811
  // correct results to all other projects.
176714
176812
  var defaultProjectResults = perProjectResults.get(defaultProject);
176715
- if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
176813
+ if (((_b = (_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined) {
176716
176814
  // Clear all isDefinition properties
176717
176815
  perProjectResults.forEach(function (projectResults) {
176718
176816
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -176729,8 +176827,8 @@ var ts;
176729
176827
  var knownSymbolSpans_1 = createDocumentSpanSet();
176730
176828
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
176731
176829
  var referencedSymbol = defaultProjectResults_1[_i];
176732
- for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
176733
- var ref = _c[_b];
176830
+ for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
176831
+ var ref = _d[_c];
176734
176832
  if (ref.isDefinition) {
176735
176833
  knownSymbolSpans_1.add(ref);
176736
176834
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -176849,23 +176947,30 @@ var ts;
176849
176947
  var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
176850
176948
  defaultDefinition :
176851
176949
  defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
176852
- // Track which projects we have already searched so that we don't repeat searches.
176853
- // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
176854
- // (For that same reason, we don't use `resultsMap` for this check.)
176855
- var searchedProjects = new ts.Set();
176950
+ // The keys of resultsMap allow us to check which projects have already been searched, but we also
176951
+ // maintain a set of strings because that's what `loadAncestorProjectTree` wants.
176952
+ var searchedProjectKeys = new ts.Set();
176856
176953
  onCancellation: while (queue.length) {
176857
176954
  while (queue.length) {
176858
176955
  if (cancellationToken.isCancellationRequested())
176859
176956
  break onCancellation;
176957
+ var skipCount = 0;
176958
+ for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
176959
+ ;
176960
+ if (skipCount === queue.length) {
176961
+ queue.length = 0;
176962
+ break;
176963
+ }
176964
+ if (skipCount > 0) {
176965
+ queue.splice(0, skipCount);
176966
+ }
176967
+ // NB: we may still skip if it's a project reference redirect
176860
176968
  var _a = queue.shift(), project = _a.project, location = _a.location;
176861
176969
  if (isLocationProjectReferenceRedirect(project, location))
176862
176970
  continue;
176863
- if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
176864
- continue;
176865
176971
  var projectResults = searchPosition(project, location);
176866
- if (projectResults) {
176867
- resultsMap.set(project, projectResults);
176868
- }
176972
+ resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
176973
+ searchedProjectKeys.add(getProjectKey(project));
176869
176974
  }
176870
176975
  // At this point, we know about all projects passed in as arguments and any projects in which
176871
176976
  // `getResultsForPosition` has returned results. We expand that set to include any projects
@@ -176873,11 +176978,11 @@ var ts;
176873
176978
  // containing `initialLocation`.
176874
176979
  if (defaultDefinition) {
176875
176980
  // This seems to mean "load all projects downstream from any member of `seenProjects`".
176876
- projectService.loadAncestorProjectTree(searchedProjects);
176981
+ projectService.loadAncestorProjectTree(searchedProjectKeys);
176877
176982
  projectService.forEachEnabledProject(function (project) {
176878
176983
  if (cancellationToken.isCancellationRequested())
176879
176984
  return; // There's no mechanism for skipping the remaining projects
176880
- if (searchedProjects.has(getProjectKey(project)))
176985
+ if (resultsMap.has(project))
176881
176986
  return; // Can loop forever without this (enqueue here, dequeue above, repeat)
176882
176987
  var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
176883
176988
  if (location) {
@@ -176888,9 +176993,10 @@ var ts;
176888
176993
  }
176889
176994
  // In the common case where there's only one project, return a simpler result to make
176890
176995
  // it easier for the caller to skip post-processing.
176891
- if (searchedProjects.size === 1) {
176996
+ if (resultsMap.size === 1) {
176892
176997
  var it = resultsMap.values().next();
176893
- return it.done ? server.emptyArray : it.value; // There may not be any results at all
176998
+ ts.Debug.assert(!it.done);
176999
+ return it.value;
176894
177000
  }
176895
177001
  return resultsMap;
176896
177002
  function searchPosition(project, location) {
@@ -176907,7 +177013,7 @@ var ts;
176907
177013
  var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
176908
177014
  for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
176909
177015
  var project_1 = _a[_i];
176910
- if (!project_1.isOrphan()) {
177016
+ if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
176911
177017
  queue.push({ project: project_1, location: originalLocation });
176912
177018
  }
176913
177019
  }
@@ -176916,7 +177022,7 @@ var ts;
176916
177022
  symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
176917
177023
  for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
176918
177024
  var symlinkedProject = symlinkedProjects_2[_i];
176919
- if (!symlinkedProject.isOrphan()) {
177025
+ if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
176920
177026
  queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
176921
177027
  }
176922
177028
  }
@@ -178209,7 +178315,8 @@ var ts;
178209
178315
  Session.prototype.getRenameInfo = function (args) {
178210
178316
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
178211
178317
  var position = this.getPositionInFile(args, file);
178212
- return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath });
178318
+ var preferences = this.getPreferences(file);
178319
+ return project.getLanguageService().getRenameInfo(file, position, preferences);
178213
178320
  };
178214
178321
  Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
178215
178322
  var _a;
@@ -178260,10 +178367,11 @@ var ts;
178260
178367
  var position = this.getPositionInFile(args, file);
178261
178368
  var projects = this.getProjects(args);
178262
178369
  var defaultProject = this.getDefaultProject(args);
178263
- var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178370
+ var preferences = this.getPreferences(file);
178371
+ var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178264
178372
  if (!renameInfo.canRename)
178265
178373
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
178266
- var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
178374
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
178267
178375
  if (!simplifiedResult)
178268
178376
  return locations;
178269
178377
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
@@ -4137,6 +4137,7 @@ declare namespace ts {
4137
4137
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
4138
4138
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4139
4139
  readonly includeInlayEnumMemberValueHints?: boolean;
4140
+ readonly allowRenameOfImportPath?: boolean;
4140
4141
  }
4141
4142
  /** Represents a bigint literal value without requiring bigint support */
4142
4143
  export interface PseudoBigInt {
@@ -5917,6 +5918,8 @@ declare namespace ts {
5917
5918
  getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
5918
5919
  getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined;
5919
5920
  getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined;
5921
+ getRenameInfo(fileName: string, position: number, preferences: UserPreferences): RenameInfo;
5922
+ /** @deprecated Use the signature with `UserPreferences` instead. */
5920
5923
  getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo;
5921
5924
  findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined;
5922
5925
  getSmartSelectionRange(fileName: string, position: number): SelectionRange;
@@ -6296,6 +6299,7 @@ declare namespace ts {
6296
6299
  Insert = "insert",
6297
6300
  Remove = "remove"
6298
6301
  }
6302
+ /** @deprecated - consider using EditorSettings instead */
6299
6303
  interface EditorOptions {
6300
6304
  BaseIndentSize?: number;
6301
6305
  IndentSize: number;
@@ -6313,6 +6317,7 @@ declare namespace ts {
6313
6317
  indentStyle?: IndentStyle;
6314
6318
  trimTrailingWhitespace?: boolean;
6315
6319
  }
6320
+ /** @deprecated - consider using FormatCodeSettings instead */
6316
6321
  interface FormatCodeOptions extends EditorOptions {
6317
6322
  InsertSpaceAfterCommaDelimiter: boolean;
6318
6323
  InsertSpaceAfterSemicolonInForStatements: boolean;
@@ -6438,6 +6443,9 @@ declare namespace ts {
6438
6443
  canRename: false;
6439
6444
  localizedErrorMessage: string;
6440
6445
  }
6446
+ /**
6447
+ * @deprecated Use `UserPreferences` instead.
6448
+ */
6441
6449
  interface RenameInfoOptions {
6442
6450
  readonly allowRenameOfImportPath?: boolean;
6443
6451
  }