typescript 4.6.0-dev.20220127 → 4.6.0-dev.20220131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220127";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220131";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -7855,7 +7855,7 @@ var ts;
7855
7855
  }
7856
7856
  })(ts || (ts = {}));
7857
7857
  // <auto-generated />
7858
- // generated from './diagnosticInformationMap.generated.ts' by 'src/compiler'
7858
+ // generated from './diagnosticMessages.json' in 'src/compiler'
7859
7859
  /* @internal */
7860
7860
  var ts;
7861
7861
  (function (ts) {
@@ -9443,9 +9443,8 @@ var ts;
9443
9443
  Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
9444
9444
  Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
9445
9445
  Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
9446
- Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
9446
+ Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
9447
9447
  Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
9448
- Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
9449
9448
  Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
9450
9449
  Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
9451
9450
  Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
@@ -9462,8 +9461,6 @@ var ts;
9462
9461
  Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
9463
9462
  Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
9464
9463
  Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
9465
- Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
9466
- Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
9467
9464
  Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
9468
9465
  Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
9469
9466
  Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
@@ -9475,6 +9472,8 @@ var ts;
9475
9472
  Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
9476
9473
  Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
9477
9474
  Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
9475
+ Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9476
+ Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9478
9477
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9479
9478
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9480
9479
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -20873,6 +20872,59 @@ var ts;
20873
20872
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
20874
20873
  }
20875
20874
  ts.isThisTypeParameter = isThisTypeParameter;
20875
+ function getNodeModulePathParts(fullPath) {
20876
+ // If fullPath can't be valid module file within node_modules, returns undefined.
20877
+ // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
20878
+ // Returns indices: ^ ^ ^ ^
20879
+ var topLevelNodeModulesIndex = 0;
20880
+ var topLevelPackageNameIndex = 0;
20881
+ var packageRootIndex = 0;
20882
+ var fileNameIndex = 0;
20883
+ var States;
20884
+ (function (States) {
20885
+ States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
20886
+ States[States["NodeModules"] = 1] = "NodeModules";
20887
+ States[States["Scope"] = 2] = "Scope";
20888
+ States[States["PackageContent"] = 3] = "PackageContent";
20889
+ })(States || (States = {}));
20890
+ var partStart = 0;
20891
+ var partEnd = 0;
20892
+ var state = 0 /* BeforeNodeModules */;
20893
+ while (partEnd >= 0) {
20894
+ partStart = partEnd;
20895
+ partEnd = fullPath.indexOf("/", partStart + 1);
20896
+ switch (state) {
20897
+ case 0 /* BeforeNodeModules */:
20898
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
20899
+ topLevelNodeModulesIndex = partStart;
20900
+ topLevelPackageNameIndex = partEnd;
20901
+ state = 1 /* NodeModules */;
20902
+ }
20903
+ break;
20904
+ case 1 /* NodeModules */:
20905
+ case 2 /* Scope */:
20906
+ if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
20907
+ state = 2 /* Scope */;
20908
+ }
20909
+ else {
20910
+ packageRootIndex = partEnd;
20911
+ state = 3 /* PackageContent */;
20912
+ }
20913
+ break;
20914
+ case 3 /* PackageContent */:
20915
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
20916
+ state = 1 /* NodeModules */;
20917
+ }
20918
+ else {
20919
+ state = 3 /* PackageContent */;
20920
+ }
20921
+ break;
20922
+ }
20923
+ }
20924
+ fileNameIndex = partStart;
20925
+ return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
20926
+ }
20927
+ ts.getNodeModulePathParts = getNodeModulePathParts;
20876
20928
  })(ts || (ts = {}));
20877
20929
  /* @internal */
20878
20930
  var ts;
@@ -48767,24 +48819,19 @@ var ts;
48767
48819
  error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
48768
48820
  }
48769
48821
  }
48770
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
48771
- checkSymbolUsageInExpressionContext(result, name, errorLocation);
48822
+ if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
48823
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
48824
+ if (typeOnlyDeclaration) {
48825
+ var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
48826
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
48827
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
48828
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
48829
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
48830
+ }
48772
48831
  }
48773
48832
  }
48774
48833
  return result;
48775
48834
  }
48776
- function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
48777
- if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
48778
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
48779
- if (typeOnlyDeclaration) {
48780
- var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
48781
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
48782
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
48783
- var unescapedName = ts.unescapeLeadingUnderscores(name);
48784
- addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
48785
- }
48786
- }
48787
- }
48788
48835
  function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
48789
48836
  if (!typeOnlyDeclaration)
48790
48837
  return diagnostic;
@@ -85681,7 +85728,7 @@ var ts;
85681
85728
  if (quickResult !== undefined) {
85682
85729
  return quickResult;
85683
85730
  }
85684
- var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride;
85731
+ var lastStatic, lastDeclare, lastAsync, lastOverride;
85685
85732
  var flags = 0 /* None */;
85686
85733
  for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
85687
85734
  var modifier = _a[_i];
@@ -85785,7 +85832,6 @@ var ts;
85785
85832
  return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
85786
85833
  }
85787
85834
  flags |= 64 /* Readonly */;
85788
- lastReadonly = modifier;
85789
85835
  break;
85790
85836
  case 93 /* ExportKeyword */:
85791
85837
  if (flags & 1 /* Export */) {
@@ -85898,18 +85944,12 @@ var ts;
85898
85944
  if (flags & 32 /* Static */) {
85899
85945
  return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
85900
85946
  }
85901
- if (flags & 128 /* Abstract */) {
85902
- return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
85903
- }
85904
85947
  if (flags & 16384 /* Override */) {
85905
85948
  return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
85906
85949
  }
85907
- else if (flags & 256 /* Async */) {
85950
+ if (flags & 256 /* Async */) {
85908
85951
  return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
85909
85952
  }
85910
- else if (flags & 64 /* Readonly */) {
85911
- return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
85912
- }
85913
85953
  return false;
85914
85954
  }
85915
85955
  else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
@@ -120050,7 +120090,7 @@ var ts;
120050
120090
  if (!host.fileExists || !host.readFile) {
120051
120091
  return undefined;
120052
120092
  }
120053
- var parts = getNodeModulePathParts(path);
120093
+ var parts = ts.getNodeModulePathParts(path);
120054
120094
  if (!parts) {
120055
120095
  return undefined;
120056
120096
  }
@@ -120173,58 +120213,6 @@ var ts;
120173
120213
  }
120174
120214
  }
120175
120215
  }
120176
- function getNodeModulePathParts(fullPath) {
120177
- // If fullPath can't be valid module file within node_modules, returns undefined.
120178
- // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
120179
- // Returns indices: ^ ^ ^ ^
120180
- var topLevelNodeModulesIndex = 0;
120181
- var topLevelPackageNameIndex = 0;
120182
- var packageRootIndex = 0;
120183
- var fileNameIndex = 0;
120184
- var States;
120185
- (function (States) {
120186
- States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
120187
- States[States["NodeModules"] = 1] = "NodeModules";
120188
- States[States["Scope"] = 2] = "Scope";
120189
- States[States["PackageContent"] = 3] = "PackageContent";
120190
- })(States || (States = {}));
120191
- var partStart = 0;
120192
- var partEnd = 0;
120193
- var state = 0 /* BeforeNodeModules */;
120194
- while (partEnd >= 0) {
120195
- partStart = partEnd;
120196
- partEnd = fullPath.indexOf("/", partStart + 1);
120197
- switch (state) {
120198
- case 0 /* BeforeNodeModules */:
120199
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120200
- topLevelNodeModulesIndex = partStart;
120201
- topLevelPackageNameIndex = partEnd;
120202
- state = 1 /* NodeModules */;
120203
- }
120204
- break;
120205
- case 1 /* NodeModules */:
120206
- case 2 /* Scope */:
120207
- if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
120208
- state = 2 /* Scope */;
120209
- }
120210
- else {
120211
- packageRootIndex = partEnd;
120212
- state = 3 /* PackageContent */;
120213
- }
120214
- break;
120215
- case 3 /* PackageContent */:
120216
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120217
- state = 1 /* NodeModules */;
120218
- }
120219
- else {
120220
- state = 3 /* PackageContent */;
120221
- }
120222
- break;
120223
- }
120224
- }
120225
- fileNameIndex = partStart;
120226
- return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
120227
- }
120228
120216
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
120229
120217
  return ts.firstDefined(rootDirs, function (rootDir) {
120230
120218
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
@@ -126694,6 +126682,17 @@ var ts;
126694
126682
  var exportInfoId = 1;
126695
126683
  var exportInfo = ts.createMultiMap();
126696
126684
  var symbols = new ts.Map();
126685
+ /**
126686
+ * Key: node_modules package name (no @types).
126687
+ * Value: path to deepest node_modules folder seen that is
126688
+ * both visible to `usableByFileName` and contains the package.
126689
+ *
126690
+ * Later, we can see if a given SymbolExportInfo is shadowed by
126691
+ * a another installation of the same package in a deeper
126692
+ * node_modules folder by seeing if its path starts with the
126693
+ * value stored here.
126694
+ */
126695
+ var packages = new ts.Map();
126697
126696
  var usableByFileName;
126698
126697
  var cache = {
126699
126698
  isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
@@ -126708,6 +126707,27 @@ var ts;
126708
126707
  cache.clear();
126709
126708
  usableByFileName = importingFile;
126710
126709
  }
126710
+ var packageName;
126711
+ if (moduleFile) {
126712
+ var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
126713
+ if (nodeModulesPathParts) {
126714
+ var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
126715
+ packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
126716
+ if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
126717
+ var prevDeepestNodeModulesPath = packages.get(packageName);
126718
+ var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
126719
+ if (prevDeepestNodeModulesPath) {
126720
+ var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
126721
+ if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
126722
+ packages.set(packageName, nodeModulesPath);
126723
+ }
126724
+ }
126725
+ else {
126726
+ packages.set(packageName, nodeModulesPath);
126727
+ }
126728
+ }
126729
+ }
126730
+ }
126711
126731
  var isDefault = exportKind === 1 /* Default */;
126712
126732
  var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126713
126733
  // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
@@ -126734,6 +126754,7 @@ var ts;
126734
126754
  moduleName: moduleName,
126735
126755
  moduleFile: moduleFile,
126736
126756
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
126757
+ packageName: packageName,
126737
126758
  exportKind: exportKind,
126738
126759
  targetFlags: target.flags,
126739
126760
  isFromPackageJson: isFromPackageJson,
@@ -126753,13 +126774,16 @@ var ts;
126753
126774
  exportInfo.forEach(function (info, key) {
126754
126775
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126755
126776
  var rehydrated = info.map(rehydrateCachedInfo);
126756
- action(rehydrated, function (preferCapitalized) {
126757
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126758
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126759
- return preferCapitalized
126760
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126761
- : symbolName;
126762
- }, !!ambientModuleName, key);
126777
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126778
+ if (filtered.length) {
126779
+ action(filtered, function (preferCapitalized) {
126780
+ var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126781
+ var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126782
+ return preferCapitalized
126783
+ ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126784
+ : symbolName;
126785
+ }, !!ambientModuleName, key);
126786
+ }
126763
126787
  });
126764
126788
  },
126765
126789
  releaseSymbols: function () {
@@ -126859,6 +126883,12 @@ var ts;
126859
126883
  }
126860
126884
  return true;
126861
126885
  }
126886
+ function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
126887
+ if (!packageName || !info.moduleFileName)
126888
+ return true;
126889
+ var packageDeepestNodeModulesPath = packages.get(packageName);
126890
+ return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
126891
+ }
126862
126892
  }
126863
126893
  ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
126864
126894
  function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
@@ -129169,7 +129199,7 @@ var ts;
129169
129199
  }
129170
129200
  switch (completionData.kind) {
129171
129201
  case 0 /* Data */:
129172
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
129202
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
129173
129203
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129174
129204
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129175
129205
  }
@@ -129289,7 +129319,7 @@ var ts;
129289
129319
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129290
129320
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129291
129321
  }
129292
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129322
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
129293
129323
  var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
129294
129324
  // Verify if the file is JSX language variant
129295
129325
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129302,7 +129332,7 @@ var ts;
129302
129332
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129303
129333
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129304
129334
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129305
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
129335
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
129306
129336
  }
129307
129337
  else {
129308
129338
  if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
@@ -129312,16 +129342,23 @@ var ts;
129312
129342
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129313
129343
  }
129314
129344
  if (keywordFilters !== 0 /* None */) {
129315
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129345
+ var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
129316
129346
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
129317
129347
  var keywordEntry = _a[_i];
129318
- if (!entryNames.has(keywordEntry.name)) {
129348
+ if (!entryNames_1.has(keywordEntry.name)) {
129319
129349
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129320
129350
  }
129321
129351
  }
129322
129352
  }
129323
- for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
129324
- var literal = literals_1[_b];
129353
+ var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129354
+ for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
129355
+ var keywordEntry = _c[_b];
129356
+ if (!entryNames.has(keywordEntry.name)) {
129357
+ ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129358
+ }
129359
+ }
129360
+ for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
129361
+ var literal = literals_1[_d];
129325
129362
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
129326
129363
  }
129327
129364
  return {
@@ -131871,6 +131908,34 @@ var ts;
131871
131908
  function keywordForNode(node) {
131872
131909
  return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
131873
131910
  }
131911
+ function getContextualKeywords(contextToken, position) {
131912
+ var entries = [];
131913
+ /**
131914
+ * An `AssertClause` can come after an import declaration:
131915
+ * import * from "foo" |
131916
+ * import "foo" |
131917
+ * or after a re-export declaration that has a module specifier:
131918
+ * export { foo } from "foo" |
131919
+ * Source: https://tc39.es/proposal-import-assertions/
131920
+ */
131921
+ if (contextToken) {
131922
+ var file = contextToken.getSourceFile();
131923
+ var parent = contextToken.parent;
131924
+ var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
131925
+ var currentLine = file.getLineAndCharacterOfPosition(position).line;
131926
+ if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
131927
+ && contextToken === parent.moduleSpecifier
131928
+ && tokenLine === currentLine) {
131929
+ entries.push({
131930
+ name: ts.tokenToString(129 /* AssertKeyword */),
131931
+ kind: "keyword" /* keyword */,
131932
+ kindModifiers: "" /* none */,
131933
+ sortText: SortText.GlobalsOrKeywords,
131934
+ });
131935
+ }
131936
+ }
131937
+ return entries;
131938
+ }
131874
131939
  /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
131875
131940
  function getJsDocTagAtPosition(node, position) {
131876
131941
  return ts.findAncestor(node, function (n) {
@@ -149223,9 +149288,10 @@ var ts;
149223
149288
  var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
149224
149289
  if (!info)
149225
149290
  return undefined;
149226
- var fixes = info.fixes, symbolName = info.symbolName;
149291
+ var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
149227
149292
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
149228
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, program.getCompilerOptions()); });
149293
+ return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
149294
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
149229
149295
  },
149230
149296
  fixIds: [importFixId],
149231
149297
  getAllCodeActions: function (context) {
@@ -149264,7 +149330,7 @@ var ts;
149264
149330
  var useRequire = shouldUseRequire(sourceFile, program);
149265
149331
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149266
149332
  if (fix) {
149267
- addImport({ fixes: [fix], symbolName: symbolName });
149333
+ addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
149268
149334
  }
149269
149335
  }
149270
149336
  function addImport(info) {
@@ -149435,7 +149501,8 @@ var ts;
149435
149501
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
149436
149502
  return {
149437
149503
  moduleSpecifier: fix.moduleSpecifier,
149438
- codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
149504
+ codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
149505
+ /*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
149439
149506
  };
149440
149507
  }
149441
149508
  codefix.getImportCompletionAction = getImportCompletionAction;
@@ -149443,7 +149510,8 @@ var ts;
149443
149510
  var compilerOptions = program.getCompilerOptions();
149444
149511
  var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
149445
149512
  var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
149446
- return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
149513
+ var includeSymbolNameInDescription = symbolName !== symbolToken.text;
149514
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
149447
149515
  }
149448
149516
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149449
149517
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
@@ -149736,7 +149804,7 @@ var ts;
149736
149804
  else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
149737
149805
  var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
149738
149806
  var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
149739
- return fix && { fixes: [fix], symbolName: symbolName_1 };
149807
+ return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
149740
149808
  }
149741
149809
  else {
149742
149810
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
@@ -149781,6 +149849,7 @@ var ts;
149781
149849
  return 0 /* EqualTo */;
149782
149850
  }
149783
149851
  function getFixesInfoForUMDImport(_a, token) {
149852
+ var _b;
149784
149853
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
149785
149854
  var checker = program.getTypeChecker();
149786
149855
  var umdSymbol = getUmdSymbol(token, checker);
@@ -149791,7 +149860,7 @@ var ts;
149791
149860
  var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
149792
149861
  var useRequire = shouldUseRequire(sourceFile, program);
149793
149862
  var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
149794
- return { fixes: fixes, symbolName: symbolName };
149863
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
149795
149864
  }
149796
149865
  function getUmdSymbol(token, checker) {
149797
149866
  // try the identifier to see if it is the umd symbol
@@ -149862,7 +149931,7 @@ var ts;
149862
149931
  var _ = _a[0], exportInfos = _a[1];
149863
149932
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
149864
149933
  }));
149865
- return { fixes: fixes, symbolName: symbolName };
149934
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
149866
149935
  }
149867
149936
  function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
149868
149937
  var checker = program.getTypeChecker();
@@ -149957,14 +150026,14 @@ var ts;
149957
150026
  // allowSyntheticDefaultImports/esModuleInterop is enabled.
149958
150027
  return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
149959
150028
  }
149960
- function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150029
+ function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
149961
150030
  var diag;
149962
150031
  var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
149963
- diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
150032
+ diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
149964
150033
  });
149965
150034
  return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
149966
150035
  }
149967
- function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150036
+ function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
149968
150037
  switch (fix.kind) {
149969
150038
  case 0 /* UseNamespace */:
149970
150039
  addNamespaceQualifier(changes, sourceFile, fix);
@@ -149976,11 +150045,9 @@ var ts;
149976
150045
  var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
149977
150046
  doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
149978
150047
  var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
149979
- return [
149980
- importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1,
149981
- symbolName,
149982
- moduleSpecifierWithoutQuotes
149983
- ]; // you too!
150048
+ return includeSymbolNameInDescription
150049
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
150050
+ : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
149984
150051
  }
149985
150052
  case 3 /* AddNew */: {
149986
150053
  var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
@@ -149989,7 +150056,9 @@ var ts;
149989
150056
  var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
149990
150057
  var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
149991
150058
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
149992
- return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150059
+ return includeSymbolNameInDescription
150060
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
150061
+ : [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
149993
150062
  }
149994
150063
  case 4 /* PromoteTypeOnly */: {
149995
150064
  var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
@@ -157849,14 +157918,22 @@ var ts;
157849
157918
  var result = [];
157850
157919
  return visitor(selection) ? undefined : result;
157851
157920
  function visitor(node) {
157852
- var _a;
157853
157921
  if (ts.isTypeReferenceNode(node)) {
157854
157922
  if (ts.isIdentifier(node.typeName)) {
157855
- var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
157856
- var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration);
157857
- if (declaration) {
157858
- if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) {
157859
- ts.pushIfUnique(result, declaration);
157923
+ var typeName = node.typeName;
157924
+ var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
157925
+ for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) {
157926
+ var decl = _a[_i];
157927
+ if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
157928
+ // skip extraction if the type node is in the range of the type parameter declaration.
157929
+ // function foo<T extends { a?: /**/T }>(): void;
157930
+ if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
157931
+ return true;
157932
+ }
157933
+ if (rangeContainsSkipTrivia(statement, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
157934
+ ts.pushIfUnique(result, decl);
157935
+ break;
157936
+ }
157860
157937
  }
157861
157938
  }
157862
157939
  }