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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220127";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220128";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -9637,9 +9637,8 @@ var ts;
9637
9637
  Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
9638
9638
  Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
9639
9639
  Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
9640
- Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
9640
+ Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
9641
9641
  Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
9642
- 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}\""),
9643
9642
  Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
9644
9643
  Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
9645
9644
  Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
@@ -9656,8 +9655,6 @@ var ts;
9656
9655
  Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
9657
9656
  Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
9658
9657
  Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
9659
- Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
9660
- 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}\""),
9661
9658
  Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
9662
9659
  Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
9663
9660
  Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
@@ -9669,6 +9666,8 @@ var ts;
9669
9666
  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}'"),
9670
9667
  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}\""),
9671
9668
  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}\""),
9669
+ Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9670
+ Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9672
9671
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9673
9672
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9674
9673
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -21067,6 +21066,59 @@ var ts;
21067
21066
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
21068
21067
  }
21069
21068
  ts.isThisTypeParameter = isThisTypeParameter;
21069
+ function getNodeModulePathParts(fullPath) {
21070
+ // If fullPath can't be valid module file within node_modules, returns undefined.
21071
+ // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
21072
+ // Returns indices: ^ ^ ^ ^
21073
+ var topLevelNodeModulesIndex = 0;
21074
+ var topLevelPackageNameIndex = 0;
21075
+ var packageRootIndex = 0;
21076
+ var fileNameIndex = 0;
21077
+ var States;
21078
+ (function (States) {
21079
+ States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
21080
+ States[States["NodeModules"] = 1] = "NodeModules";
21081
+ States[States["Scope"] = 2] = "Scope";
21082
+ States[States["PackageContent"] = 3] = "PackageContent";
21083
+ })(States || (States = {}));
21084
+ var partStart = 0;
21085
+ var partEnd = 0;
21086
+ var state = 0 /* BeforeNodeModules */;
21087
+ while (partEnd >= 0) {
21088
+ partStart = partEnd;
21089
+ partEnd = fullPath.indexOf("/", partStart + 1);
21090
+ switch (state) {
21091
+ case 0 /* BeforeNodeModules */:
21092
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
21093
+ topLevelNodeModulesIndex = partStart;
21094
+ topLevelPackageNameIndex = partEnd;
21095
+ state = 1 /* NodeModules */;
21096
+ }
21097
+ break;
21098
+ case 1 /* NodeModules */:
21099
+ case 2 /* Scope */:
21100
+ if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
21101
+ state = 2 /* Scope */;
21102
+ }
21103
+ else {
21104
+ packageRootIndex = partEnd;
21105
+ state = 3 /* PackageContent */;
21106
+ }
21107
+ break;
21108
+ case 3 /* PackageContent */:
21109
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
21110
+ state = 1 /* NodeModules */;
21111
+ }
21112
+ else {
21113
+ state = 3 /* PackageContent */;
21114
+ }
21115
+ break;
21116
+ }
21117
+ }
21118
+ fileNameIndex = partStart;
21119
+ return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21120
+ }
21121
+ ts.getNodeModulePathParts = getNodeModulePathParts;
21070
21122
  })(ts || (ts = {}));
21071
21123
  /* @internal */
21072
21124
  var ts;
@@ -48961,24 +49013,19 @@ var ts;
48961
49013
  error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
48962
49014
  }
48963
49015
  }
48964
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
48965
- checkSymbolUsageInExpressionContext(result, name, errorLocation);
49016
+ if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
49017
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
49018
+ if (typeOnlyDeclaration) {
49019
+ var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
49020
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
49021
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
49022
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
49023
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
49024
+ }
48966
49025
  }
48967
49026
  }
48968
49027
  return result;
48969
49028
  }
48970
- function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
48971
- if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
48972
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
48973
- if (typeOnlyDeclaration) {
48974
- var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
48975
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
48976
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
48977
- var unescapedName = ts.unescapeLeadingUnderscores(name);
48978
- addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
48979
- }
48980
- }
48981
- }
48982
49029
  function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
48983
49030
  if (!typeOnlyDeclaration)
48984
49031
  return diagnostic;
@@ -120244,7 +120291,7 @@ var ts;
120244
120291
  if (!host.fileExists || !host.readFile) {
120245
120292
  return undefined;
120246
120293
  }
120247
- var parts = getNodeModulePathParts(path);
120294
+ var parts = ts.getNodeModulePathParts(path);
120248
120295
  if (!parts) {
120249
120296
  return undefined;
120250
120297
  }
@@ -120367,58 +120414,6 @@ var ts;
120367
120414
  }
120368
120415
  }
120369
120416
  }
120370
- function getNodeModulePathParts(fullPath) {
120371
- // If fullPath can't be valid module file within node_modules, returns undefined.
120372
- // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
120373
- // Returns indices: ^ ^ ^ ^
120374
- var topLevelNodeModulesIndex = 0;
120375
- var topLevelPackageNameIndex = 0;
120376
- var packageRootIndex = 0;
120377
- var fileNameIndex = 0;
120378
- var States;
120379
- (function (States) {
120380
- States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
120381
- States[States["NodeModules"] = 1] = "NodeModules";
120382
- States[States["Scope"] = 2] = "Scope";
120383
- States[States["PackageContent"] = 3] = "PackageContent";
120384
- })(States || (States = {}));
120385
- var partStart = 0;
120386
- var partEnd = 0;
120387
- var state = 0 /* BeforeNodeModules */;
120388
- while (partEnd >= 0) {
120389
- partStart = partEnd;
120390
- partEnd = fullPath.indexOf("/", partStart + 1);
120391
- switch (state) {
120392
- case 0 /* BeforeNodeModules */:
120393
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120394
- topLevelNodeModulesIndex = partStart;
120395
- topLevelPackageNameIndex = partEnd;
120396
- state = 1 /* NodeModules */;
120397
- }
120398
- break;
120399
- case 1 /* NodeModules */:
120400
- case 2 /* Scope */:
120401
- if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
120402
- state = 2 /* Scope */;
120403
- }
120404
- else {
120405
- packageRootIndex = partEnd;
120406
- state = 3 /* PackageContent */;
120407
- }
120408
- break;
120409
- case 3 /* PackageContent */:
120410
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120411
- state = 1 /* NodeModules */;
120412
- }
120413
- else {
120414
- state = 3 /* PackageContent */;
120415
- }
120416
- break;
120417
- }
120418
- }
120419
- fileNameIndex = partStart;
120420
- return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
120421
- }
120422
120417
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
120423
120418
  return ts.firstDefined(rootDirs, function (rootDir) {
120424
120419
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
@@ -127305,6 +127300,17 @@ var ts;
127305
127300
  var exportInfoId = 1;
127306
127301
  var exportInfo = ts.createMultiMap();
127307
127302
  var symbols = new ts.Map();
127303
+ /**
127304
+ * Key: node_modules package name (no @types).
127305
+ * Value: path to deepest node_modules folder seen that is
127306
+ * both visible to `usableByFileName` and contains the package.
127307
+ *
127308
+ * Later, we can see if a given SymbolExportInfo is shadowed by
127309
+ * a another installation of the same package in a deeper
127310
+ * node_modules folder by seeing if its path starts with the
127311
+ * value stored here.
127312
+ */
127313
+ var packages = new ts.Map();
127308
127314
  var usableByFileName;
127309
127315
  var cache = {
127310
127316
  isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
@@ -127319,6 +127325,27 @@ var ts;
127319
127325
  cache.clear();
127320
127326
  usableByFileName = importingFile;
127321
127327
  }
127328
+ var packageName;
127329
+ if (moduleFile) {
127330
+ var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
127331
+ if (nodeModulesPathParts) {
127332
+ var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
127333
+ packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
127334
+ if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
127335
+ var prevDeepestNodeModulesPath = packages.get(packageName);
127336
+ var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
127337
+ if (prevDeepestNodeModulesPath) {
127338
+ var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
127339
+ if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
127340
+ packages.set(packageName, nodeModulesPath);
127341
+ }
127342
+ }
127343
+ else {
127344
+ packages.set(packageName, nodeModulesPath);
127345
+ }
127346
+ }
127347
+ }
127348
+ }
127322
127349
  var isDefault = exportKind === 1 /* Default */;
127323
127350
  var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127324
127351
  // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
@@ -127345,6 +127372,7 @@ var ts;
127345
127372
  moduleName: moduleName,
127346
127373
  moduleFile: moduleFile,
127347
127374
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
127375
+ packageName: packageName,
127348
127376
  exportKind: exportKind,
127349
127377
  targetFlags: target.flags,
127350
127378
  isFromPackageJson: isFromPackageJson,
@@ -127364,13 +127392,16 @@ var ts;
127364
127392
  exportInfo.forEach(function (info, key) {
127365
127393
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
127366
127394
  var rehydrated = info.map(rehydrateCachedInfo);
127367
- action(rehydrated, function (preferCapitalized) {
127368
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
127369
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127370
- return preferCapitalized
127371
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
127372
- : symbolName;
127373
- }, !!ambientModuleName, key);
127395
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
127396
+ if (filtered.length) {
127397
+ action(filtered, function (preferCapitalized) {
127398
+ var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
127399
+ var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127400
+ return preferCapitalized
127401
+ ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
127402
+ : symbolName;
127403
+ }, !!ambientModuleName, key);
127404
+ }
127374
127405
  });
127375
127406
  },
127376
127407
  releaseSymbols: function () {
@@ -127470,6 +127501,12 @@ var ts;
127470
127501
  }
127471
127502
  return true;
127472
127503
  }
127504
+ function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
127505
+ if (!packageName || !info.moduleFileName)
127506
+ return true;
127507
+ var packageDeepestNodeModulesPath = packages.get(packageName);
127508
+ return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
127509
+ }
127473
127510
  }
127474
127511
  ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
127475
127512
  function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
@@ -129780,7 +129817,7 @@ var ts;
129780
129817
  }
129781
129818
  switch (completionData.kind) {
129782
129819
  case 0 /* Data */:
129783
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
129820
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
129784
129821
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129785
129822
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129786
129823
  }
@@ -129900,7 +129937,7 @@ var ts;
129900
129937
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129901
129938
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129902
129939
  }
129903
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129940
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
129904
129941
  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;
129905
129942
  // Verify if the file is JSX language variant
129906
129943
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129913,7 +129950,7 @@ var ts;
129913
129950
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129914
129951
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129915
129952
  /*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);
129916
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
129953
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
129917
129954
  }
129918
129955
  else {
129919
129956
  if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
@@ -129923,16 +129960,23 @@ var ts;
129923
129960
  /*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);
129924
129961
  }
129925
129962
  if (keywordFilters !== 0 /* None */) {
129926
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129963
+ var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
129927
129964
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
129928
129965
  var keywordEntry = _a[_i];
129929
- if (!entryNames.has(keywordEntry.name)) {
129966
+ if (!entryNames_1.has(keywordEntry.name)) {
129930
129967
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129931
129968
  }
129932
129969
  }
129933
129970
  }
129934
- for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
129935
- var literal = literals_1[_b];
129971
+ var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129972
+ for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
129973
+ var keywordEntry = _c[_b];
129974
+ if (!entryNames.has(keywordEntry.name)) {
129975
+ ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129976
+ }
129977
+ }
129978
+ for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
129979
+ var literal = literals_1[_d];
129936
129980
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
129937
129981
  }
129938
129982
  return {
@@ -132482,6 +132526,34 @@ var ts;
132482
132526
  function keywordForNode(node) {
132483
132527
  return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
132484
132528
  }
132529
+ function getContextualKeywords(contextToken, position) {
132530
+ var entries = [];
132531
+ /**
132532
+ * An `AssertClause` can come after an import declaration:
132533
+ * import * from "foo" |
132534
+ * import "foo" |
132535
+ * or after a re-export declaration that has a module specifier:
132536
+ * export { foo } from "foo" |
132537
+ * Source: https://tc39.es/proposal-import-assertions/
132538
+ */
132539
+ if (contextToken) {
132540
+ var file = contextToken.getSourceFile();
132541
+ var parent = contextToken.parent;
132542
+ var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
132543
+ var currentLine = file.getLineAndCharacterOfPosition(position).line;
132544
+ if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
132545
+ && contextToken === parent.moduleSpecifier
132546
+ && tokenLine === currentLine) {
132547
+ entries.push({
132548
+ name: ts.tokenToString(129 /* AssertKeyword */),
132549
+ kind: "keyword" /* keyword */,
132550
+ kindModifiers: "" /* none */,
132551
+ sortText: SortText.GlobalsOrKeywords,
132552
+ });
132553
+ }
132554
+ }
132555
+ return entries;
132556
+ }
132485
132557
  /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
132486
132558
  function getJsDocTagAtPosition(node, position) {
132487
132559
  return ts.findAncestor(node, function (n) {
@@ -149834,9 +149906,10 @@ var ts;
149834
149906
  var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
149835
149907
  if (!info)
149836
149908
  return undefined;
149837
- var fixes = info.fixes, symbolName = info.symbolName;
149909
+ var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
149838
149910
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
149839
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, program.getCompilerOptions()); });
149911
+ return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
149912
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
149840
149913
  },
149841
149914
  fixIds: [importFixId],
149842
149915
  getAllCodeActions: function (context) {
@@ -149875,7 +149948,7 @@ var ts;
149875
149948
  var useRequire = shouldUseRequire(sourceFile, program);
149876
149949
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149877
149950
  if (fix) {
149878
- addImport({ fixes: [fix], symbolName: symbolName });
149951
+ addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
149879
149952
  }
149880
149953
  }
149881
149954
  function addImport(info) {
@@ -150046,7 +150119,8 @@ var ts;
150046
150119
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
150047
150120
  return {
150048
150121
  moduleSpecifier: fix.moduleSpecifier,
150049
- codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
150122
+ codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
150123
+ /*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
150050
150124
  };
150051
150125
  }
150052
150126
  codefix.getImportCompletionAction = getImportCompletionAction;
@@ -150054,7 +150128,8 @@ var ts;
150054
150128
  var compilerOptions = program.getCompilerOptions();
150055
150129
  var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
150056
150130
  var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
150057
- return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
150131
+ var includeSymbolNameInDescription = symbolName !== symbolToken.text;
150132
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
150058
150133
  }
150059
150134
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
150060
150135
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
@@ -150347,7 +150422,7 @@ var ts;
150347
150422
  else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
150348
150423
  var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
150349
150424
  var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
150350
- return fix && { fixes: [fix], symbolName: symbolName_1 };
150425
+ return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
150351
150426
  }
150352
150427
  else {
150353
150428
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
@@ -150392,6 +150467,7 @@ var ts;
150392
150467
  return 0 /* EqualTo */;
150393
150468
  }
150394
150469
  function getFixesInfoForUMDImport(_a, token) {
150470
+ var _b;
150395
150471
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
150396
150472
  var checker = program.getTypeChecker();
150397
150473
  var umdSymbol = getUmdSymbol(token, checker);
@@ -150402,7 +150478,7 @@ var ts;
150402
150478
  var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150403
150479
  var useRequire = shouldUseRequire(sourceFile, program);
150404
150480
  var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150405
- return { fixes: fixes, symbolName: symbolName };
150481
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
150406
150482
  }
150407
150483
  function getUmdSymbol(token, checker) {
150408
150484
  // try the identifier to see if it is the umd symbol
@@ -150473,7 +150549,7 @@ var ts;
150473
150549
  var _ = _a[0], exportInfos = _a[1];
150474
150550
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
150475
150551
  }));
150476
- return { fixes: fixes, symbolName: symbolName };
150552
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
150477
150553
  }
150478
150554
  function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
150479
150555
  var checker = program.getTypeChecker();
@@ -150568,14 +150644,14 @@ var ts;
150568
150644
  // allowSyntheticDefaultImports/esModuleInterop is enabled.
150569
150645
  return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
150570
150646
  }
150571
- function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150647
+ function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
150572
150648
  var diag;
150573
150649
  var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
150574
- diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
150650
+ diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
150575
150651
  });
150576
150652
  return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
150577
150653
  }
150578
- function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150654
+ function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
150579
150655
  switch (fix.kind) {
150580
150656
  case 0 /* UseNamespace */:
150581
150657
  addNamespaceQualifier(changes, sourceFile, fix);
@@ -150587,11 +150663,9 @@ var ts;
150587
150663
  var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
150588
150664
  doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
150589
150665
  var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
150590
- return [
150591
- 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,
150592
- symbolName,
150593
- moduleSpecifierWithoutQuotes
150594
- ]; // you too!
150666
+ return includeSymbolNameInDescription
150667
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
150668
+ : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
150595
150669
  }
150596
150670
  case 3 /* AddNew */: {
150597
150671
  var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
@@ -150600,7 +150674,9 @@ var ts;
150600
150674
  var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
150601
150675
  var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
150602
150676
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150603
- return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150677
+ return includeSymbolNameInDescription
150678
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
150679
+ : [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
150604
150680
  }
150605
150681
  case 4 /* PromoteTypeOnly */: {
150606
150682
  var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;