typescript 4.6.0-dev.20220127 → 4.6.0-dev.20220128

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.20220128";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -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;
@@ -120050,7 +120097,7 @@ var ts;
120050
120097
  if (!host.fileExists || !host.readFile) {
120051
120098
  return undefined;
120052
120099
  }
120053
- var parts = getNodeModulePathParts(path);
120100
+ var parts = ts.getNodeModulePathParts(path);
120054
120101
  if (!parts) {
120055
120102
  return undefined;
120056
120103
  }
@@ -120173,58 +120220,6 @@ var ts;
120173
120220
  }
120174
120221
  }
120175
120222
  }
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
120223
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
120229
120224
  return ts.firstDefined(rootDirs, function (rootDir) {
120230
120225
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
@@ -126694,6 +126689,17 @@ var ts;
126694
126689
  var exportInfoId = 1;
126695
126690
  var exportInfo = ts.createMultiMap();
126696
126691
  var symbols = new ts.Map();
126692
+ /**
126693
+ * Key: node_modules package name (no @types).
126694
+ * Value: path to deepest node_modules folder seen that is
126695
+ * both visible to `usableByFileName` and contains the package.
126696
+ *
126697
+ * Later, we can see if a given SymbolExportInfo is shadowed by
126698
+ * a another installation of the same package in a deeper
126699
+ * node_modules folder by seeing if its path starts with the
126700
+ * value stored here.
126701
+ */
126702
+ var packages = new ts.Map();
126697
126703
  var usableByFileName;
126698
126704
  var cache = {
126699
126705
  isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
@@ -126708,6 +126714,27 @@ var ts;
126708
126714
  cache.clear();
126709
126715
  usableByFileName = importingFile;
126710
126716
  }
126717
+ var packageName;
126718
+ if (moduleFile) {
126719
+ var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
126720
+ if (nodeModulesPathParts) {
126721
+ var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
126722
+ packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
126723
+ if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
126724
+ var prevDeepestNodeModulesPath = packages.get(packageName);
126725
+ var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
126726
+ if (prevDeepestNodeModulesPath) {
126727
+ var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
126728
+ if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
126729
+ packages.set(packageName, nodeModulesPath);
126730
+ }
126731
+ }
126732
+ else {
126733
+ packages.set(packageName, nodeModulesPath);
126734
+ }
126735
+ }
126736
+ }
126737
+ }
126711
126738
  var isDefault = exportKind === 1 /* Default */;
126712
126739
  var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126713
126740
  // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
@@ -126734,6 +126761,7 @@ var ts;
126734
126761
  moduleName: moduleName,
126735
126762
  moduleFile: moduleFile,
126736
126763
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
126764
+ packageName: packageName,
126737
126765
  exportKind: exportKind,
126738
126766
  targetFlags: target.flags,
126739
126767
  isFromPackageJson: isFromPackageJson,
@@ -126753,13 +126781,16 @@ var ts;
126753
126781
  exportInfo.forEach(function (info, key) {
126754
126782
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126755
126783
  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);
126784
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126785
+ if (filtered.length) {
126786
+ action(filtered, function (preferCapitalized) {
126787
+ var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126788
+ var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126789
+ return preferCapitalized
126790
+ ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126791
+ : symbolName;
126792
+ }, !!ambientModuleName, key);
126793
+ }
126763
126794
  });
126764
126795
  },
126765
126796
  releaseSymbols: function () {
@@ -126859,6 +126890,12 @@ var ts;
126859
126890
  }
126860
126891
  return true;
126861
126892
  }
126893
+ function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
126894
+ if (!packageName || !info.moduleFileName)
126895
+ return true;
126896
+ var packageDeepestNodeModulesPath = packages.get(packageName);
126897
+ return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
126898
+ }
126862
126899
  }
126863
126900
  ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
126864
126901
  function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
@@ -129169,7 +129206,7 @@ var ts;
129169
129206
  }
129170
129207
  switch (completionData.kind) {
129171
129208
  case 0 /* Data */:
129172
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
129209
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
129173
129210
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129174
129211
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129175
129212
  }
@@ -129289,7 +129326,7 @@ var ts;
129289
129326
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129290
129327
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129291
129328
  }
129292
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129329
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
129293
129330
  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
129331
  // Verify if the file is JSX language variant
129295
129332
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129302,7 +129339,7 @@ var ts;
129302
129339
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129303
129340
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129304
129341
  /*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
129342
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
129306
129343
  }
129307
129344
  else {
129308
129345
  if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
@@ -129312,16 +129349,23 @@ var ts;
129312
129349
  /*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
129350
  }
129314
129351
  if (keywordFilters !== 0 /* None */) {
129315
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129352
+ var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
129316
129353
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
129317
129354
  var keywordEntry = _a[_i];
129318
- if (!entryNames.has(keywordEntry.name)) {
129355
+ if (!entryNames_1.has(keywordEntry.name)) {
129319
129356
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129320
129357
  }
129321
129358
  }
129322
129359
  }
129323
- for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
129324
- var literal = literals_1[_b];
129360
+ var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129361
+ for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
129362
+ var keywordEntry = _c[_b];
129363
+ if (!entryNames.has(keywordEntry.name)) {
129364
+ ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129365
+ }
129366
+ }
129367
+ for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
129368
+ var literal = literals_1[_d];
129325
129369
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
129326
129370
  }
129327
129371
  return {
@@ -131871,6 +131915,34 @@ var ts;
131871
131915
  function keywordForNode(node) {
131872
131916
  return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
131873
131917
  }
131918
+ function getContextualKeywords(contextToken, position) {
131919
+ var entries = [];
131920
+ /**
131921
+ * An `AssertClause` can come after an import declaration:
131922
+ * import * from "foo" |
131923
+ * import "foo" |
131924
+ * or after a re-export declaration that has a module specifier:
131925
+ * export { foo } from "foo" |
131926
+ * Source: https://tc39.es/proposal-import-assertions/
131927
+ */
131928
+ if (contextToken) {
131929
+ var file = contextToken.getSourceFile();
131930
+ var parent = contextToken.parent;
131931
+ var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
131932
+ var currentLine = file.getLineAndCharacterOfPosition(position).line;
131933
+ if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
131934
+ && contextToken === parent.moduleSpecifier
131935
+ && tokenLine === currentLine) {
131936
+ entries.push({
131937
+ name: ts.tokenToString(129 /* AssertKeyword */),
131938
+ kind: "keyword" /* keyword */,
131939
+ kindModifiers: "" /* none */,
131940
+ sortText: SortText.GlobalsOrKeywords,
131941
+ });
131942
+ }
131943
+ }
131944
+ return entries;
131945
+ }
131874
131946
  /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
131875
131947
  function getJsDocTagAtPosition(node, position) {
131876
131948
  return ts.findAncestor(node, function (n) {
@@ -149223,9 +149295,10 @@ var ts;
149223
149295
  var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
149224
149296
  if (!info)
149225
149297
  return undefined;
149226
- var fixes = info.fixes, symbolName = info.symbolName;
149298
+ var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
149227
149299
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
149228
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, program.getCompilerOptions()); });
149300
+ return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
149301
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
149229
149302
  },
149230
149303
  fixIds: [importFixId],
149231
149304
  getAllCodeActions: function (context) {
@@ -149264,7 +149337,7 @@ var ts;
149264
149337
  var useRequire = shouldUseRequire(sourceFile, program);
149265
149338
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149266
149339
  if (fix) {
149267
- addImport({ fixes: [fix], symbolName: symbolName });
149340
+ addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
149268
149341
  }
149269
149342
  }
149270
149343
  function addImport(info) {
@@ -149435,7 +149508,8 @@ var ts;
149435
149508
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
149436
149509
  return {
149437
149510
  moduleSpecifier: fix.moduleSpecifier,
149438
- codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
149511
+ codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
149512
+ /*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
149439
149513
  };
149440
149514
  }
149441
149515
  codefix.getImportCompletionAction = getImportCompletionAction;
@@ -149443,7 +149517,8 @@ var ts;
149443
149517
  var compilerOptions = program.getCompilerOptions();
149444
149518
  var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
149445
149519
  var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
149446
- return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
149520
+ var includeSymbolNameInDescription = symbolName !== symbolToken.text;
149521
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
149447
149522
  }
149448
149523
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149449
149524
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
@@ -149736,7 +149811,7 @@ var ts;
149736
149811
  else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
149737
149812
  var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
149738
149813
  var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
149739
- return fix && { fixes: [fix], symbolName: symbolName_1 };
149814
+ return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
149740
149815
  }
149741
149816
  else {
149742
149817
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
@@ -149781,6 +149856,7 @@ var ts;
149781
149856
  return 0 /* EqualTo */;
149782
149857
  }
149783
149858
  function getFixesInfoForUMDImport(_a, token) {
149859
+ var _b;
149784
149860
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
149785
149861
  var checker = program.getTypeChecker();
149786
149862
  var umdSymbol = getUmdSymbol(token, checker);
@@ -149791,7 +149867,7 @@ var ts;
149791
149867
  var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
149792
149868
  var useRequire = shouldUseRequire(sourceFile, program);
149793
149869
  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 };
149870
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
149795
149871
  }
149796
149872
  function getUmdSymbol(token, checker) {
149797
149873
  // try the identifier to see if it is the umd symbol
@@ -149862,7 +149938,7 @@ var ts;
149862
149938
  var _ = _a[0], exportInfos = _a[1];
149863
149939
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
149864
149940
  }));
149865
- return { fixes: fixes, symbolName: symbolName };
149941
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
149866
149942
  }
149867
149943
  function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
149868
149944
  var checker = program.getTypeChecker();
@@ -149957,14 +150033,14 @@ var ts;
149957
150033
  // allowSyntheticDefaultImports/esModuleInterop is enabled.
149958
150034
  return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
149959
150035
  }
149960
- function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150036
+ function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
149961
150037
  var diag;
149962
150038
  var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
149963
- diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
150039
+ diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
149964
150040
  });
149965
150041
  return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
149966
150042
  }
149967
- function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150043
+ function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
149968
150044
  switch (fix.kind) {
149969
150045
  case 0 /* UseNamespace */:
149970
150046
  addNamespaceQualifier(changes, sourceFile, fix);
@@ -149976,11 +150052,9 @@ var ts;
149976
150052
  var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
149977
150053
  doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
149978
150054
  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!
150055
+ return includeSymbolNameInDescription
150056
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
150057
+ : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
149984
150058
  }
149985
150059
  case 3 /* AddNew */: {
149986
150060
  var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
@@ -149989,7 +150063,9 @@ var ts;
149989
150063
  var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
149990
150064
  var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
149991
150065
  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];
150066
+ return includeSymbolNameInDescription
150067
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
150068
+ : [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
149993
150069
  }
149994
150070
  case 4 /* PromoteTypeOnly */: {
149995
150071
  var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;