typescript 4.6.0-dev.20220123 → 4.6.0-dev.20220127

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.20220123";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220127";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -305,13 +305,18 @@ var ts;
305
305
  /* @internal */
306
306
  var NativeCollections;
307
307
  (function (NativeCollections) {
308
+ var globals = typeof globalThis !== "undefined" ? globalThis :
309
+ typeof global !== "undefined" ? global :
310
+ typeof self !== "undefined" ? self :
311
+ undefined;
308
312
  /**
309
313
  * Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
310
314
  */
311
315
  function tryGetNativeMap() {
312
316
  // Internet Explorer's Map doesn't support iteration, so don't use it.
317
+ var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
313
318
  // eslint-disable-next-line no-in-operator
314
- return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
319
+ return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
315
320
  }
316
321
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
317
322
  /**
@@ -319,8 +324,9 @@ var ts;
319
324
  */
320
325
  function tryGetNativeSet() {
321
326
  // Internet Explorer's Set doesn't support iteration, so don't use it.
327
+ var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
322
328
  // eslint-disable-next-line no-in-operator
323
- return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
329
+ return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
324
330
  }
325
331
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
326
332
  })(NativeCollections || (NativeCollections = {}));
@@ -9661,6 +9667,8 @@ var ts;
9661
9667
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9662
9668
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9663
9669
  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
+ 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
+ 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}\""),
9664
9672
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9665
9673
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9666
9674
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -14251,10 +14259,13 @@ var ts;
14251
14259
  function packageIdIsEqual(a, b) {
14252
14260
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
14253
14261
  }
14254
- function packageIdToString(_a) {
14255
- var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
14256
- var fullName = subModuleName ? name + "/" + subModuleName : name;
14257
- return fullName + "@" + version;
14262
+ function packageIdToPackageName(_a) {
14263
+ var name = _a.name, subModuleName = _a.subModuleName;
14264
+ return subModuleName ? name + "/" + subModuleName : name;
14265
+ }
14266
+ ts.packageIdToPackageName = packageIdToPackageName;
14267
+ function packageIdToString(packageId) {
14268
+ return packageIdToPackageName(packageId) + "@" + packageId.version;
14258
14269
  }
14259
14270
  ts.packageIdToString = packageIdToString;
14260
14271
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
@@ -15087,6 +15098,15 @@ var ts;
15087
15098
  };
15088
15099
  }
15089
15100
  ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
15101
+ function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
15102
+ return typeof diagnostic.messageText === "string" ? {
15103
+ code: diagnostic.code,
15104
+ category: diagnostic.category,
15105
+ messageText: diagnostic.messageText,
15106
+ next: diagnostic.next,
15107
+ } : diagnostic.messageText;
15108
+ }
15109
+ ts.createDiagnosticMessageChainFromDiagnostic = createDiagnosticMessageChainFromDiagnostic;
15090
15110
  function createDiagnosticForRange(sourceFile, range, message) {
15091
15111
  return {
15092
15112
  file: sourceFile,
@@ -15255,7 +15275,8 @@ var ts;
15255
15275
  node.kind === 212 /* FunctionExpression */ ||
15256
15276
  node.kind === 213 /* ArrowFunction */ ||
15257
15277
  node.kind === 211 /* ParenthesizedExpression */ ||
15258
- node.kind === 253 /* VariableDeclaration */) ?
15278
+ node.kind === 253 /* VariableDeclaration */ ||
15279
+ node.kind === 274 /* ExportSpecifier */) ?
15259
15280
  ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
15260
15281
  ts.getLeadingCommentRanges(text, node.pos);
15261
15282
  // True if the comment starts with '/**' but not if it is '/**/'
@@ -36406,7 +36427,8 @@ var ts;
36406
36427
  return finishNode(node, pos);
36407
36428
  }
36408
36429
  function parseExportSpecifier() {
36409
- return parseImportOrExportSpecifier(274 /* ExportSpecifier */);
36430
+ var hasJSDoc = hasPrecedingJSDocComment();
36431
+ return withJSDoc(parseImportOrExportSpecifier(274 /* ExportSpecifier */), hasJSDoc);
36410
36432
  }
36411
36433
  function parseImportSpecifier() {
36412
36434
  return parseImportOrExportSpecifier(269 /* ImportSpecifier */);
@@ -43611,14 +43633,12 @@ var ts;
43611
43633
  }
43612
43634
  var binder = createBinder();
43613
43635
  function bindSourceFile(file, options) {
43614
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
43615
43636
  ts.performance.mark("beforeBind");
43616
43637
  ts.perfLogger.logStartBindFile("" + file.fileName);
43617
43638
  binder(file, options);
43618
43639
  ts.perfLogger.logStopBindFile();
43619
43640
  ts.performance.mark("afterBind");
43620
43641
  ts.performance.measure("Bind", "beforeBind", "afterBind");
43621
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
43622
43642
  }
43623
43643
  ts.bindSourceFile = bindSourceFile;
43624
43644
  function createBinder() {
@@ -43678,7 +43698,9 @@ var ts;
43678
43698
  ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
43679
43699
  ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
43680
43700
  if (!file.locals) {
43701
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
43681
43702
  bind(file);
43703
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
43682
43704
  file.symbolCount = symbolCount;
43683
43705
  file.classifiableNames = classifiableNames;
43684
43706
  delayedBindJSDocTypedefTag();
@@ -47945,6 +47967,9 @@ var ts;
47945
47967
  suggestionDiagnostics.add(diagnostic);
47946
47968
  return diagnostic;
47947
47969
  }
47970
+ function isDeprecatedSymbol(symbol) {
47971
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
47972
+ }
47948
47973
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
47949
47974
  var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
47950
47975
  return addDeprecatedSuggestionWorker(declarations, diagnostic);
@@ -52715,7 +52740,8 @@ var ts;
52715
52740
  includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
52716
52741
  }
52717
52742
  if (ts.isIdentifier(node)) {
52718
- var name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.factory.cloneNode(node);
52743
+ var type = getDeclaredTypeOfSymbol(sym);
52744
+ var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
52719
52745
  name.symbol = sym; // for quickinfo, which uses identifier symbol information
52720
52746
  return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
52721
52747
  }
@@ -60731,7 +60757,7 @@ var ts;
60731
60757
  }
60732
60758
  var prop = getPropertyOfType(objectType, propName);
60733
60759
  if (prop) {
60734
- if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) {
60760
+ if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
60735
60761
  var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
60736
60762
  addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
60737
60763
  }
@@ -70134,9 +70160,9 @@ var ts;
70134
70160
  markAliasReferenced(symbol, node);
70135
70161
  }
70136
70162
  var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
70137
- var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
70138
- if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) {
70139
- addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText);
70163
+ var targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node);
70164
+ if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) {
70165
+ addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
70140
70166
  }
70141
70167
  var declaration = localOrExportSymbol.valueDeclaration;
70142
70168
  if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
@@ -73148,7 +73174,7 @@ var ts;
73148
73174
  }
73149
73175
  }
73150
73176
  else {
73151
- if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
73177
+ if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
73152
73178
  addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
73153
73179
  }
73154
73180
  checkPropertyNotUsedBeforeDeclaration(prop, node, right);
@@ -74607,7 +74633,7 @@ var ts;
74607
74633
  }
74608
74634
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
74609
74635
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
74610
- var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call);
74636
+ var chain = ts.chainDiagnosticMessages(ts.map(diags_3, ts.createDiagnosticMessageChainFromDiagnostic), ts.Diagnostics.No_overload_matches_this_call);
74611
74637
  // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input
74612
74638
  // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
74613
74639
  var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
@@ -82986,16 +83012,15 @@ var ts;
82986
83012
  return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
82987
83013
  case 206 /* ElementAccessExpression */:
82988
83014
  case 205 /* PropertyAccessExpression */:
82989
- var ex = expr;
82990
- if (isConstantMemberAccess(ex)) {
82991
- var type = getTypeOfExpression(ex.expression);
83015
+ if (isConstantMemberAccess(expr)) {
83016
+ var type = getTypeOfExpression(expr.expression);
82992
83017
  if (type.symbol && type.symbol.flags & 384 /* Enum */) {
82993
83018
  var name = void 0;
82994
- if (ex.kind === 205 /* PropertyAccessExpression */) {
82995
- name = ex.name.escapedText;
83019
+ if (expr.kind === 205 /* PropertyAccessExpression */) {
83020
+ name = expr.name.escapedText;
82996
83021
  }
82997
83022
  else {
82998
- name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
83023
+ name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
82999
83024
  }
83000
83025
  return evaluateEnumMember(expr, type.symbol, name);
83001
83026
  }
@@ -83023,6 +83048,10 @@ var ts;
83023
83048
  }
83024
83049
  }
83025
83050
  function isConstantMemberAccess(node) {
83051
+ var type = getTypeOfExpression(node);
83052
+ if (type === errorType) {
83053
+ return false;
83054
+ }
83026
83055
  return node.kind === 79 /* Identifier */ ||
83027
83056
  node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
83028
83057
  node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
@@ -83317,7 +83346,6 @@ var ts;
83317
83346
  return true;
83318
83347
  }
83319
83348
  function checkAliasSymbol(node) {
83320
- var _a;
83321
83349
  var symbol = getSymbolOfNode(node);
83322
83350
  var target = resolveAlias(symbol);
83323
83351
  if (target !== unknownSymbol) {
@@ -83373,10 +83401,45 @@ var ts;
83373
83401
  }
83374
83402
  }
83375
83403
  }
83376
- if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) {
83377
- addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName);
83404
+ if (ts.isImportSpecifier(node)) {
83405
+ var targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
83406
+ if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
83407
+ addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName);
83408
+ }
83409
+ }
83410
+ }
83411
+ }
83412
+ function isDeprecatedAliasedSymbol(symbol) {
83413
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
83414
+ }
83415
+ function checkDeprecatedAliasedSymbol(symbol, location) {
83416
+ if (!(symbol.flags & 2097152 /* Alias */))
83417
+ return symbol;
83418
+ var targetSymbol = resolveAlias(symbol);
83419
+ if (targetSymbol === unknownSymbol)
83420
+ return targetSymbol;
83421
+ while (symbol.flags & 2097152 /* Alias */) {
83422
+ var target = getImmediateAliasedSymbol(symbol);
83423
+ if (target) {
83424
+ if (target === targetSymbol)
83425
+ break;
83426
+ if (target.declarations && ts.length(target.declarations)) {
83427
+ if (isDeprecatedAliasedSymbol(target)) {
83428
+ addDeprecatedSuggestion(location, target.declarations, target.escapedName);
83429
+ break;
83430
+ }
83431
+ else {
83432
+ if (symbol === targetSymbol)
83433
+ break;
83434
+ symbol = target;
83435
+ }
83436
+ }
83437
+ }
83438
+ else {
83439
+ break;
83378
83440
  }
83379
83441
  }
83442
+ return targetSymbol;
83380
83443
  }
83381
83444
  function checkImportBinding(node) {
83382
83445
  checkCollisionsForDeclarationName(node, node.name);
@@ -116035,14 +116098,14 @@ var ts;
116035
116098
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
116036
116099
  addFileToFilesByName(dupFile, path, redirectedPath);
116037
116100
  addFileIncludeReason(dupFile, reason);
116038
- sourceFileToPackageName.set(path, packageId.name);
116101
+ sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
116039
116102
  processingOtherFiles.push(dupFile);
116040
116103
  return dupFile;
116041
116104
  }
116042
116105
  else if (file) {
116043
116106
  // This is the first source file to have this packageId.
116044
116107
  packageIdToSourceFile.set(packageIdKey, file);
116045
- sourceFileToPackageName.set(path, packageId.name);
116108
+ sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
116046
116109
  }
116047
116110
  }
116048
116111
  addFileToFilesByName(file, path, redirectedPath);
@@ -127119,11 +127182,11 @@ var ts;
127119
127182
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
127120
127183
  }
127121
127184
  ts.firstOrOnly = firstOrOnly;
127122
- function getNameForExportedSymbol(symbol, scriptTarget) {
127185
+ function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
127123
127186
  if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
127124
127187
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
127125
127188
  return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; })
127126
- || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
127189
+ || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
127127
127190
  }
127128
127191
  return symbol.name;
127129
127192
  }
@@ -127251,7 +127314,7 @@ var ts;
127251
127314
  symbols.clear();
127252
127315
  usableByFileName = undefined;
127253
127316
  },
127254
- add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, scriptTarget, checker) {
127317
+ add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
127255
127318
  if (importingFile !== usableByFileName) {
127256
127319
  cache.clear();
127257
127320
  usableByFileName = importingFile;
@@ -127267,7 +127330,7 @@ var ts;
127267
127330
  // get a better name.
127268
127331
  var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127269
127332
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
127270
- : ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
127333
+ : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127271
127334
  var moduleName = ts.stripQuotes(moduleSymbol.name);
127272
127335
  var id = exportInfoId++;
127273
127336
  var target = ts.skipAlias(symbol, checker);
@@ -127300,7 +127363,14 @@ var ts;
127300
127363
  return;
127301
127364
  exportInfo.forEach(function (info, key) {
127302
127365
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
127303
- action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key);
127366
+ 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);
127304
127374
  });
127305
127375
  },
127306
127376
  releaseSymbols: function () {
@@ -127482,7 +127552,6 @@ var ts;
127482
127552
  }
127483
127553
  (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
127484
127554
  var compilerOptions = program.getCompilerOptions();
127485
- var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
127486
127555
  var moduleCount = 0;
127487
127556
  forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
127488
127557
  if (++moduleCount % 100 === 0)
@@ -127493,11 +127562,11 @@ var ts;
127493
127562
  // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
127494
127563
  // can cause it to happen: see 'completionsImport_mergedReExport.ts'
127495
127564
  if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
127496
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, scriptTarget, checker);
127565
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
127497
127566
  }
127498
127567
  checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
127499
127568
  if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
127500
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker);
127569
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
127501
127570
  }
127502
127571
  });
127503
127572
  });
@@ -129571,6 +129640,8 @@ var ts;
129571
129640
  CompletionSource["ThisProperty"] = "ThisProperty/";
129572
129641
  /** Auto-import that comes attached to a class member snippet */
129573
129642
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
129643
+ /** A type-only import that needs to be promoted in order to be used at the completion location */
129644
+ CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
129574
129645
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
129575
129646
  var SymbolOriginInfoKind;
129576
129647
  (function (SymbolOriginInfoKind) {
@@ -129580,6 +129651,7 @@ var ts;
129580
129651
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
129581
129652
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
129582
129653
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129654
+ SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
129583
129655
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
129584
129656
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
129585
129657
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -129607,6 +129679,9 @@ var ts;
129607
129679
  function originIsNullableMember(origin) {
129608
129680
  return !!(origin.kind & 16 /* Nullable */);
129609
129681
  }
129682
+ function originIsTypeOnlyAlias(origin) {
129683
+ return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129684
+ }
129610
129685
  var KeywordCompletionFilters;
129611
129686
  (function (KeywordCompletionFilters) {
129612
129687
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -130011,6 +130086,9 @@ var ts;
130011
130086
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
130012
130087
  }
130013
130088
  }
130089
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130090
+ hasAction = true;
130091
+ }
130014
130092
  if (preferences.includeCompletionsWithClassMemberSnippets &&
130015
130093
  preferences.includeCompletionsWithInsertText &&
130016
130094
  completionKind === 3 /* MemberLike */ &&
@@ -130355,6 +130433,9 @@ var ts;
130355
130433
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
130356
130434
  return CompletionSource.ThisProperty;
130357
130435
  }
130436
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130437
+ return CompletionSource.TypeOnlyAlias;
130438
+ }
130358
130439
  }
130359
130440
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
130360
130441
  var _a;
@@ -130382,7 +130463,7 @@ var ts;
130382
130463
  continue;
130383
130464
  }
130384
130465
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
130385
- var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130466
+ var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130386
130467
  uniques.set(name, shouldShadowLaterSymbols);
130387
130468
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
130388
130469
  }
@@ -130395,6 +130476,7 @@ var ts;
130395
130476
  add: function (name) { return uniques.set(name, true); },
130396
130477
  };
130397
130478
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
130479
+ var allFlags = symbol.flags;
130398
130480
  if (!ts.isSourceFile(location)) {
130399
130481
  // export = /**/ here we want to get all meanings, so any symbol is ok
130400
130482
  if (ts.isExportAssignment(location.parent)) {
@@ -130420,11 +130502,10 @@ var ts;
130420
130502
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
130421
130503
  return false;
130422
130504
  }
130423
- // Continue with origin symbol
130424
- symbol = symbolOrigin;
130505
+ allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
130425
130506
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
130426
130507
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
130427
- return !!(symbol.flags & 1920 /* Namespace */);
130508
+ return !!(allFlags & 1920 /* Namespace */);
130428
130509
  }
130429
130510
  if (isTypeOnlyLocation) {
130430
130511
  // It's a type, but you can reach it by namespace.type as well
@@ -130432,7 +130513,7 @@ var ts;
130432
130513
  }
130433
130514
  }
130434
130515
  // expressions are value space (which includes the value namespaces)
130435
- return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
130516
+ return !!(allFlags & 111551 /* Value */);
130436
130517
  }
130437
130518
  }
130438
130519
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130566,8 +130647,7 @@ var ts;
130566
130647
  Completions.createCompletionDetails = createCompletionDetails;
130567
130648
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
130568
130649
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
130569
- var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
130570
- if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
130650
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
130571
130651
  // Import statement completion: 'import c|'
130572
130652
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
130573
130653
  }
@@ -130585,13 +130665,19 @@ var ts;
130585
130665
  };
130586
130666
  }
130587
130667
  }
130668
+ if (originIsTypeOnlyAlias(origin)) {
130669
+ var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
130670
+ ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
130671
+ return { codeActions: [codeAction_1], sourceDisplay: undefined };
130672
+ }
130588
130673
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130589
130674
  return { codeActions: undefined, sourceDisplay: undefined };
130590
130675
  }
130591
130676
  var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
130592
130677
  var moduleSymbol = origin.moduleSymbol;
130593
130678
  var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
130594
- var _b = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions)), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _b.moduleSpecifier, codeAction = _b.codeAction;
130679
+ var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
130680
+ var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
130595
130681
  ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
130596
130682
  return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
130597
130683
  }
@@ -131261,21 +131347,29 @@ var ts;
131261
131347
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
131262
131348
  isInSnippetScope = isSnippetScope(scopeNode);
131263
131349
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
131350
+ var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
131264
131351
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
131265
131352
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
131266
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
131267
- var symbol = symbols_1[_i];
131353
+ for (var i = 0; i < symbols.length; i++) {
131354
+ var symbol = symbols[i];
131268
131355
  if (!typeChecker.isArgumentsSymbol(symbol) &&
131269
131356
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
131270
131357
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
131271
131358
  }
131359
+ if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
131360
+ var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
131361
+ if (typeOnlyAliasDeclaration) {
131362
+ var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
131363
+ symbolToOriginInfoMap[i] = origin;
131364
+ }
131365
+ }
131272
131366
  }
131273
131367
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
131274
131368
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
131275
131369
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
131276
131370
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
131277
- for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
131278
- var symbol = _b[_a];
131371
+ for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
131372
+ var symbol = _a[_i];
131279
131373
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
131280
131374
  symbols.push(symbol);
131281
131375
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -131378,7 +131472,8 @@ var ts;
131378
131472
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131379
131473
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131380
131474
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131381
- exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131475
+ exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131476
+ var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131382
131477
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131383
131478
  return;
131384
131479
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
@@ -131388,6 +131483,10 @@ var ts;
131388
131483
  return;
131389
131484
  if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131390
131485
  return;
131486
+ // Do not try to auto-import something with a lowercase first letter for a JSX tag
131487
+ var firstChar = symbolName.charCodeAt(0);
131488
+ if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131489
+ return;
131391
131490
  var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131392
131491
  if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131393
131492
  var defaultExportInfo = ts.find(info, isImportableExportInfo);
@@ -131464,16 +131563,19 @@ var ts;
131464
131563
  return true;
131465
131564
  }
131466
131565
  if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
131566
+ // <Component<string> /**/ />
131567
+ // <Component<string> /**/ ><Component>
131568
+ // - contextToken: GreaterThanToken (before cursor)
131569
+ // - location: JsxSelfClosingElement or JsxOpeningElement
131570
+ // - contextToken.parent === location
131571
+ if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
131572
+ return false;
131573
+ }
131467
131574
  if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
131468
- // Two possibilities:
131469
- // 1. <div>/**/
131470
- // - contextToken: GreaterThanToken (before cursor)
131471
- // - location: JSXElement
131472
- // - different parents (JSXOpeningElement, JSXElement)
131473
- // 2. <Component<string> /**/>
131474
- // - contextToken: GreaterThanToken (before cursor)
131475
- // - location: GreaterThanToken (after cursor)
131476
- // - same parent (JSXOpeningElement)
131575
+ // <div>/**/
131576
+ // - contextToken: GreaterThanToken (before cursor)
131577
+ // - location: JSXElement
131578
+ // - different parents (JSXOpeningElement, JSXElement)
131477
131579
  return location.parent.kind !== 279 /* JsxOpeningElement */;
131478
131580
  }
131479
131581
  if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
@@ -132674,10 +132776,14 @@ var ts;
132674
132776
  /** True if symbol is a type or a module containing at least one type. */
132675
132777
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132676
132778
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132677
- var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132678
- return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132679
- !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132680
- checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132779
+ // Since an alias can be merged with a local declaration, we need to test both the alias and its target.
132780
+ // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
132781
+ return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
132782
+ function nonAliasCanBeReferencedAtTypeLocation(symbol) {
132783
+ return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
132784
+ !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
132785
+ checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132786
+ }
132681
132787
  }
132682
132788
  function isDeprecated(symbol, checker) {
132683
132789
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -134931,8 +135037,8 @@ var ts;
134931
135037
  var sourceId = ts.getNodeId(sourceFile);
134932
135038
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134933
135039
  var anyNewSymbols = false;
134934
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134935
- var sym = symbols_2[_i];
135040
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
135041
+ var sym = symbols_1[_i];
134936
135042
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134937
135043
  }
134938
135044
  return anyNewSymbols;
@@ -141892,6 +141998,8 @@ var ts;
141892
141998
  }
141893
141999
  if (flags & 16 /* Function */)
141894
142000
  return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */;
142001
+ // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag.
142002
+ // So, even when the location is just on the declaration of setter, this function returns getter.
141895
142003
  if (flags & 32768 /* GetAccessor */)
141896
142004
  return "getter" /* memberGetAccessorElement */;
141897
142005
  if (flags & 65536 /* SetAccessor */)
@@ -141978,9 +142086,24 @@ var ts;
141978
142086
  }
141979
142087
  // Class at constructor site need to be shown as constructor apart from property,method, vars
141980
142088
  if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
141981
- // If it is accessor they are allowed only if location is at name of the accessor
142089
+ // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
141982
142090
  if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
141983
- symbolKind = "property" /* memberVariableElement */;
142091
+ var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
142092
+ if (declaration) {
142093
+ switch (declaration.kind) {
142094
+ case 171 /* GetAccessor */:
142095
+ symbolKind = "getter" /* memberGetAccessorElement */;
142096
+ break;
142097
+ case 172 /* SetAccessor */:
142098
+ symbolKind = "setter" /* memberSetAccessorElement */;
142099
+ break;
142100
+ default:
142101
+ ts.Debug.assertNever(declaration);
142102
+ }
142103
+ }
142104
+ else {
142105
+ symbolKind = "property" /* memberVariableElement */;
142106
+ }
141984
142107
  }
141985
142108
  var signature = void 0;
141986
142109
  type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
@@ -142294,6 +142417,8 @@ var ts;
142294
142417
  }
142295
142418
  // For properties, variables and local vars: show the type
142296
142419
  if (symbolKind === "property" /* memberVariableElement */ ||
142420
+ symbolKind === "getter" /* memberGetAccessorElement */ ||
142421
+ symbolKind === "setter" /* memberSetAccessorElement */ ||
142297
142422
  symbolKind === "JSX attribute" /* jsxAttribute */ ||
142298
142423
  symbolFlags & 3 /* Variable */ ||
142299
142424
  symbolKind === "local var" /* localVariableElement */ ||
@@ -142364,7 +142489,7 @@ var ts;
142364
142489
  }
142365
142490
  }
142366
142491
  if (tags.length === 0 && !hasMultipleSignatures) {
142367
- tags = symbol.getJsDocTags(typeChecker);
142492
+ tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142368
142493
  }
142369
142494
  if (documentation.length === 0 && documentationFromAlias) {
142370
142495
  documentation = documentationFromAlias;
@@ -145784,6 +145909,7 @@ var ts;
145784
145909
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145785
145910
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145786
145911
  };
145912
+ /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145787
145913
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145788
145914
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145789
145915
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -146187,6 +146313,15 @@ var ts;
146187
146313
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
146188
146314
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
146189
146315
  };
146316
+ ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
146317
+ var prevSpecifier = namedImports.elements[index - 1];
146318
+ if (prevSpecifier) {
146319
+ this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
146320
+ }
146321
+ else {
146322
+ this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
146323
+ }
146324
+ };
146190
146325
  /**
146191
146326
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
146192
146327
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -149689,7 +149824,8 @@ var ts;
149689
149824
  ts.Diagnostics.Cannot_find_namespace_0.code,
149690
149825
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149691
149826
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149692
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
149827
+ ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
149828
+ ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
149693
149829
  ];
149694
149830
  codefix.registerCodeFix({
149695
149831
  errorCodes: errorCodes,
@@ -149735,7 +149871,7 @@ var ts;
149735
149871
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
149736
149872
  var checker = program.getTypeChecker();
149737
149873
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
149738
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
149874
+ var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149739
149875
  var useRequire = shouldUseRequire(sourceFile, program);
149740
149876
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149741
149877
  if (fix) {
@@ -149794,6 +149930,9 @@ var ts;
149794
149930
  }
149795
149931
  break;
149796
149932
  }
149933
+ case 4 /* PromoteTypeOnly */:
149934
+ // Excluding from fix-all
149935
+ break;
149797
149936
  default:
149798
149937
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149799
149938
  }
@@ -149885,6 +150024,7 @@ var ts;
149885
150024
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149886
150025
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149887
150026
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
150027
+ ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149888
150028
  })(ImportFixKind || (ImportFixKind = {}));
149889
150029
  // These should not be combined as bitflags, but are given powers of 2 values to
149890
150030
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149896,11 +150036,11 @@ var ts;
149896
150036
  AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
149897
150037
  AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
149898
150038
  })(AddAsTypeOnly || (AddAsTypeOnly = {}));
149899
- function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
150039
+ function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
149900
150040
  var compilerOptions = program.getCompilerOptions();
149901
150041
  var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
149902
150042
  ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
149903
- : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
150043
+ : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
149904
150044
  var useRequire = shouldUseRequire(sourceFile, program);
149905
150045
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
149906
150046
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
@@ -149910,6 +150050,13 @@ var ts;
149910
150050
  };
149911
150051
  }
149912
150052
  codefix.getImportCompletionAction = getImportCompletionAction;
150053
+ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
150054
+ var compilerOptions = program.getCompilerOptions();
150055
+ var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
150056
+ var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
150057
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
150058
+ }
150059
+ codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149913
150060
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149914
150061
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149915
150062
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -149939,7 +150086,7 @@ var ts;
149939
150086
  }
149940
150087
  }
149941
150088
  }
149942
- function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
150089
+ function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
149943
150090
  var result = [];
149944
150091
  var compilerOptions = program.getCompilerOptions();
149945
150092
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
@@ -149952,7 +150099,7 @@ var ts;
149952
150099
  return;
149953
150100
  }
149954
150101
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149955
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
150102
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149956
150103
  result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
149957
150104
  }
149958
150105
  for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -150190,9 +150337,21 @@ var ts;
150190
150337
  }
150191
150338
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
150192
150339
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
150193
- var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
150194
- ? getFixesInfoForUMDImport(context, symbolToken)
150195
- : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
150340
+ var info;
150341
+ if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
150342
+ info = getFixesInfoForUMDImport(context, symbolToken);
150343
+ }
150344
+ else if (!ts.isIdentifier(symbolToken)) {
150345
+ return undefined;
150346
+ }
150347
+ else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
150348
+ var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
150349
+ var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
150350
+ return fix && { fixes: [fix], symbolName: symbolName_1 };
150351
+ }
150352
+ else {
150353
+ info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150354
+ }
150196
150355
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150197
150356
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150198
150357
  }
@@ -150309,13 +150468,23 @@ var ts;
150309
150468
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
150310
150469
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
150311
150470
  var useRequire = shouldUseRequire(sourceFile, program);
150312
- var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150471
+ var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150313
150472
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
150314
150473
  var _ = _a[0], exportInfos = _a[1];
150315
150474
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
150316
150475
  }));
150317
150476
  return { fixes: fixes, symbolName: symbolName };
150318
150477
  }
150478
+ function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
150479
+ var checker = program.getTypeChecker();
150480
+ var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150481
+ if (!symbol)
150482
+ return undefined;
150483
+ var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
150484
+ if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
150485
+ return undefined;
150486
+ return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150487
+ }
150319
150488
  function jsxModeNeedsExplicitImport(jsx) {
150320
150489
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150321
150490
  }
@@ -150323,14 +150492,20 @@ var ts;
150323
150492
  var parent = symbolToken.parent;
150324
150493
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150325
150494
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150326
- if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
150495
+ if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150327
150496
  return jsxNamespace;
150328
150497
  }
150329
150498
  }
150330
150499
  return symbolToken.text;
150331
150500
  }
150501
+ function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
150502
+ if (ts.isIntrinsicJsxName(symbolToken.text))
150503
+ return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
150504
+ var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150505
+ return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
150506
+ }
150332
150507
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
150333
- function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150508
+ function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150334
150509
  var _a;
150335
150510
  // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
150336
150511
  // Maps symbol id to info for modules providing that symbol (original export + re-exports).
@@ -150353,7 +150528,7 @@ var ts;
150353
150528
  cancellationToken.throwIfCancellationRequested();
150354
150529
  var compilerOptions = program.getCompilerOptions();
150355
150530
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
150356
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
150531
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
150357
150532
  addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
150358
150533
  }
150359
150534
  // check exports with the same name
@@ -150427,10 +150602,80 @@ var ts;
150427
150602
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150428
150603
  return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150429
150604
  }
150605
+ case 4 /* PromoteTypeOnly */: {
150606
+ var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
150607
+ var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
150608
+ return promotedDeclaration.kind === 269 /* ImportSpecifier */
150609
+ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
150610
+ : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
150611
+ }
150430
150612
  default:
150431
150613
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
150432
150614
  }
150433
150615
  }
150616
+ function getModuleSpecifierText(promotedDeclaration) {
150617
+ var _a, _b;
150618
+ return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
150619
+ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
150620
+ : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
150621
+ }
150622
+ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
150623
+ // See comment in `doAddExistingFix` on constant with the same name.
150624
+ var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
150625
+ switch (aliasDeclaration.kind) {
150626
+ case 269 /* ImportSpecifier */:
150627
+ if (aliasDeclaration.isTypeOnly) {
150628
+ if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
150629
+ changes.delete(sourceFile, aliasDeclaration);
150630
+ var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
150631
+ var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
150632
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
150633
+ }
150634
+ else {
150635
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
150636
+ }
150637
+ return aliasDeclaration;
150638
+ }
150639
+ else {
150640
+ ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
150641
+ promoteImportClause(aliasDeclaration.parent.parent);
150642
+ return aliasDeclaration.parent.parent;
150643
+ }
150644
+ case 266 /* ImportClause */:
150645
+ promoteImportClause(aliasDeclaration);
150646
+ return aliasDeclaration;
150647
+ case 267 /* NamespaceImport */:
150648
+ promoteImportClause(aliasDeclaration.parent);
150649
+ return aliasDeclaration.parent;
150650
+ case 264 /* ImportEqualsDeclaration */:
150651
+ changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
150652
+ return aliasDeclaration;
150653
+ default:
150654
+ ts.Debug.failBadSyntaxKind(aliasDeclaration);
150655
+ }
150656
+ function promoteImportClause(importClause) {
150657
+ changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
150658
+ if (convertExistingToTypeOnly) {
150659
+ var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
150660
+ if (namedImports && namedImports.elements.length > 1) {
150661
+ if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
150662
+ aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
150663
+ namedImports.elements.indexOf(aliasDeclaration) !== 0) {
150664
+ // The import specifier being promoted will be the only non-type-only,
150665
+ // import in the NamedImports, so it should be moved to the front.
150666
+ changes.delete(sourceFile, aliasDeclaration);
150667
+ changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
150668
+ }
150669
+ for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
150670
+ var element = _a[_i];
150671
+ if (element !== aliasDeclaration && !element.isTypeOnly) {
150672
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
150673
+ }
150674
+ }
150675
+ }
150676
+ }
150677
+ }
150678
+ }
150434
150679
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
150435
150680
  var _a;
150436
150681
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -150468,13 +150713,7 @@ var ts;
150468
150713
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
150469
150714
  ? 0
150470
150715
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
150471
- var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
150472
- if (prevSpecifier) {
150473
- changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
150474
- }
150475
- else {
150476
- changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
150477
- }
150716
+ changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
150478
150717
  }
150479
150718
  }
150480
150719
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -150589,17 +150828,20 @@ var ts;
150589
150828
  var declarations = _a.declarations;
150590
150829
  return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
150591
150830
  }
150592
- function moduleSymbolToValidIdentifier(moduleSymbol, target) {
150593
- return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
150831
+ function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
150832
+ return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
150594
150833
  }
150595
150834
  codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
150596
- function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
150835
+ function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
150597
150836
  var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
150598
150837
  var res = "";
150599
150838
  var lastCharWasValid = true;
150600
150839
  var firstCharCode = baseName.charCodeAt(0);
150601
150840
  if (ts.isIdentifierStart(firstCharCode, target)) {
150602
150841
  res += String.fromCharCode(firstCharCode);
150842
+ if (forceCapitalize) {
150843
+ res = res.toUpperCase();
150844
+ }
150603
150845
  }
150604
150846
  else {
150605
150847
  lastCharWasValid = false;
@@ -160568,13 +160810,11 @@ var ts;
160568
160810
  switch (context === null || context === void 0 ? void 0 : context.kind) {
160569
160811
  case 171 /* GetAccessor */:
160570
160812
  if (!this.contextualGetAccessorDocumentationComment) {
160571
- this.contextualGetAccessorDocumentationComment = ts.emptyArray;
160572
160813
  this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
160573
160814
  }
160574
160815
  return this.contextualGetAccessorDocumentationComment;
160575
160816
  case 172 /* SetAccessor */:
160576
160817
  if (!this.contextualSetAccessorDocumentationComment) {
160577
- this.contextualSetAccessorDocumentationComment = ts.emptyArray;
160578
160818
  this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
160579
160819
  }
160580
160820
  return this.contextualSetAccessorDocumentationComment;
@@ -160584,10 +160824,26 @@ var ts;
160584
160824
  };
160585
160825
  SymbolObject.prototype.getJsDocTags = function (checker) {
160586
160826
  if (this.tags === undefined) {
160587
- this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker);
160827
+ this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
160588
160828
  }
160589
160829
  return this.tags;
160590
160830
  };
160831
+ SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
160832
+ switch (context === null || context === void 0 ? void 0 : context.kind) {
160833
+ case 171 /* GetAccessor */:
160834
+ if (!this.contextualGetAccessorTags) {
160835
+ this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
160836
+ }
160837
+ return this.contextualGetAccessorTags;
160838
+ case 172 /* SetAccessor */:
160839
+ if (!this.contextualSetAccessorTags) {
160840
+ this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
160841
+ }
160842
+ return this.contextualSetAccessorTags;
160843
+ default:
160844
+ return this.getJsDocTags(checker);
160845
+ }
160846
+ };
160591
160847
  return SymbolObject;
160592
160848
  }());
160593
160849
  var TokenObject = /** @class */ (function (_super) {
@@ -160757,10 +161013,7 @@ var ts;
160757
161013
  return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
160758
161014
  };
160759
161015
  SignatureObject.prototype.getJsDocTags = function () {
160760
- if (this.jsDocTags === undefined) {
160761
- this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : [];
160762
- }
160763
- return this.jsDocTags;
161016
+ return this.jsDocTags || (this.jsDocTags = getJsDocTagsOfDeclarations(ts.singleElementArray(this.declaration), this.checker));
160764
161017
  };
160765
161018
  return SignatureObject;
160766
161019
  }());
@@ -160772,12 +161025,30 @@ var ts;
160772
161025
  function hasJSDocInheritDocTag(node) {
160773
161026
  return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
160774
161027
  }
160775
- function getJsDocTagsOfSignature(declaration, checker) {
160776
- var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker);
160777
- if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) {
160778
- var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; });
160779
- if (inheritedTags) {
160780
- tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
161028
+ function getJsDocTagsOfDeclarations(declarations, checker) {
161029
+ if (!declarations)
161030
+ return ts.emptyArray;
161031
+ var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
161032
+ if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
161033
+ var seenSymbols_1 = new ts.Set();
161034
+ var _loop_22 = function (declaration) {
161035
+ var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
161036
+ var _a;
161037
+ if (!seenSymbols_1.has(symbol)) {
161038
+ seenSymbols_1.add(symbol);
161039
+ if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
161040
+ return symbol.getContextualJsDocTags(declaration, checker);
161041
+ }
161042
+ return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
161043
+ }
161044
+ });
161045
+ if (inheritedTags) {
161046
+ tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
161047
+ }
161048
+ };
161049
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
161050
+ var declaration = declarations_6[_i];
161051
+ _loop_22(declaration);
160781
161052
  }
160782
161053
  }
160783
161054
  return tags;
@@ -160787,18 +161058,24 @@ var ts;
160787
161058
  return ts.emptyArray;
160788
161059
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
160789
161060
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
160790
- var seenSymbols_1 = new ts.Set();
160791
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
160792
- var declaration = declarations_6[_i];
161061
+ var seenSymbols_2 = new ts.Set();
161062
+ var _loop_23 = function (declaration) {
160793
161063
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
160794
- if (!seenSymbols_1.has(symbol)) {
160795
- seenSymbols_1.add(symbol);
161064
+ if (!seenSymbols_2.has(symbol)) {
161065
+ seenSymbols_2.add(symbol);
161066
+ if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
161067
+ return symbol.getContextualDocumentationComment(declaration, checker);
161068
+ }
160796
161069
  return symbol.getDocumentationComment(checker);
160797
161070
  }
160798
161071
  });
160799
161072
  // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
160800
161073
  if (inheritedDocs)
160801
161074
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
161075
+ };
161076
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
161077
+ var declaration = declarations_7[_i];
161078
+ _loop_23(declaration);
160802
161079
  }
160803
161080
  }
160804
161081
  return doc;