typescript 4.9.0-dev.20220813 → 4.9.0-dev.20220816

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.
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = ts.versionMajorMinor + ".0-dev.20220813";
111
+ ts.version = ts.versionMajorMinor + ".0-dev.20220816";
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -1162,6 +1162,13 @@ var ts;
1162
1162
  : undefined;
1163
1163
  }
1164
1164
  ts.singleOrUndefined = singleOrUndefined;
1165
+ /**
1166
+ * Returns the only element of an array if it contains only one element; throws otherwise.
1167
+ */
1168
+ function single(array) {
1169
+ return ts.Debug.checkDefined(singleOrUndefined(array));
1170
+ }
1171
+ ts.single = single;
1165
1172
  function singleOrMany(array) {
1166
1173
  return array && array.length === 1
1167
1174
  ? array[0]
@@ -7029,7 +7036,6 @@ var ts;
7029
7036
  // not actually work.
7030
7037
  var byteOrderMarkIndicator = "\uFEFF";
7031
7038
  function getNodeSystem() {
7032
- var _a;
7033
7039
  var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
7034
7040
  var _fs = require("fs");
7035
7041
  var _path = require("path");
@@ -7039,7 +7045,7 @@ var ts;
7039
7045
  try {
7040
7046
  _crypto = require("crypto");
7041
7047
  }
7042
- catch (_b) {
7048
+ catch (_a) {
7043
7049
  _crypto = undefined;
7044
7050
  }
7045
7051
  var activeSession;
@@ -7050,10 +7056,10 @@ var ts;
7050
7056
  var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
7051
7057
  var platform = _os.platform();
7052
7058
  var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
7053
- var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync;
7059
+ var fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
7054
7060
  var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
7055
7061
  var getCurrentDirectory = ts.memoize(function () { return process.cwd(); });
7056
- var _c = createSystemWatchFunctions({
7062
+ var _b = createSystemWatchFunctions({
7057
7063
  pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
7058
7064
  getModifiedTime: getModifiedTime,
7059
7065
  setTimeout: setTimeout,
@@ -7073,7 +7079,7 @@ var ts;
7073
7079
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7074
7080
  inodeWatching: isLinuxOrMacOs,
7075
7081
  sysLog: sysLog,
7076
- }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
7082
+ }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
7077
7083
  var nodeSystem = {
7078
7084
  args: process.argv.slice(2),
7079
7085
  newLine: _os.EOL,
@@ -7466,9 +7472,12 @@ var ts;
7466
7472
  function getDirectories(path) {
7467
7473
  return getAccessibleFileSystemEntries(path).directories.slice();
7468
7474
  }
7475
+ function fsRealPathHandlingLongPath(path) {
7476
+ return path.length < 260 ? _fs.realpathSync.native(path) : _fs.realpathSync(path);
7477
+ }
7469
7478
  function realpath(path) {
7470
7479
  try {
7471
- return realpathSync(path);
7480
+ return fsRealpath(path);
7472
7481
  }
7473
7482
  catch (_a) {
7474
7483
  return path;
@@ -8898,7 +8907,7 @@ var ts;
8898
8907
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."),
8899
8908
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."),
8900
8909
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."),
8901
- This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."),
8910
+ This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag_2594", "This module is declared with 'export =', and can only be used with a default import when using the '{0}' flag."),
8902
8911
  _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."),
8903
8912
  _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."),
8904
8913
  _0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import: diag(2597, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import_2597", "'{0}' can only be imported by using a 'require' call or by using a default import."),
@@ -18125,7 +18134,7 @@ var ts;
18125
18134
  }
18126
18135
  diagnostics = nonFileDiagnostics;
18127
18136
  }
18128
- ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
18137
+ ts.insertSorted(diagnostics, diagnostic, compareDiagnosticsSkipRelatedInformation);
18129
18138
  }
18130
18139
  function getGlobalDiagnostics() {
18131
18140
  hasReadNonFileDiagnostics = true;
@@ -51052,7 +51061,7 @@ var ts;
51052
51061
  var exportAssignment = exportEqualsSymbol.valueDeclaration;
51053
51062
  var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
51054
51063
  if (exportAssignment) {
51055
- ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName));
51064
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName));
51056
51065
  }
51057
51066
  }
51058
51067
  else {
@@ -65725,7 +65734,8 @@ var ts;
65725
65734
  return 0 /* False */;
65726
65735
  }
65727
65736
  }
65728
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
65737
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || relation === comparableRelation && isLiteralType(source)) &&
65738
+ !(intersectionState & 2 /* Target */) &&
65729
65739
  source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
65730
65740
  target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
65731
65741
  (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
@@ -66502,7 +66512,7 @@ var ts;
66502
66512
  // create a new chain for the constraint error
66503
66513
  resetErrorInfo(saveErrorInfo);
66504
66514
  }
66505
- if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
66515
+ if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors, /* headMessage */ undefined, intersectionState)) {
66506
66516
  return result;
66507
66517
  }
66508
66518
  // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
@@ -68208,7 +68218,7 @@ var ts;
68208
68218
  if (!isLiteralOfContextualType(type, contextualType)) {
68209
68219
  type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
68210
68220
  }
68211
- return type;
68221
+ return getRegularTypeOfLiteralType(type);
68212
68222
  }
68213
68223
  function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
68214
68224
  if (type && isUnitType(type)) {
@@ -138911,6 +138921,8 @@ var ts;
138911
138921
  // Similarly, skip past the symbol for 'export ='
138912
138922
  if (importedSymbol.escapedName === "export=") {
138913
138923
  importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker);
138924
+ if (importedSymbol === undefined)
138925
+ return undefined;
138914
138926
  }
138915
138927
  // If the import has a different name than the export, do not continue searching.
138916
138928
  // If `importedName` is undefined, do continue searching as the export is anonymous.
@@ -138932,19 +138944,19 @@ var ts;
138932
138944
  FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol;
138933
138945
  function getExportEqualsLocalSymbol(importedSymbol, checker) {
138934
138946
  if (importedSymbol.flags & 2097152 /* Alias */) {
138935
- return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol));
138947
+ return checker.getImmediateAliasedSymbol(importedSymbol);
138936
138948
  }
138937
138949
  var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration);
138938
138950
  if (ts.isExportAssignment(decl)) { // `export = class {}`
138939
- return ts.Debug.checkDefined(decl.expression.symbol);
138951
+ return decl.expression.symbol;
138940
138952
  }
138941
138953
  else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}`
138942
- return ts.Debug.checkDefined(decl.right.symbol);
138954
+ return decl.right.symbol;
138943
138955
  }
138944
138956
  else if (ts.isSourceFile(decl)) { // json module
138945
- return ts.Debug.checkDefined(decl.symbol);
138957
+ return decl.symbol;
138946
138958
  }
138947
- return ts.Debug.fail();
138959
+ return undefined;
138948
138960
  }
138949
138961
  // If a reference is a class expression, the exported node would be its parent.
138950
138962
  // If a reference is a variable declaration, the exported node would be the variable statement.
@@ -155221,13 +155233,15 @@ var ts;
155221
155233
  errorCodes: errorCodes,
155222
155234
  getCodeActions: function (context) {
155223
155235
  var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span, program = context.program;
155224
- var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
155236
+ var info = getFixInfos(context, errorCode, span.start, /*useAutoImportProvider*/ true);
155225
155237
  if (!info)
155226
155238
  return undefined;
155227
- var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
155228
155239
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
155229
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
155230
- /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
155240
+ return info.map(function (_a) {
155241
+ var fix = _a.fix, symbolName = _a.symbolName, errorIdentifierText = _a.errorIdentifierText;
155242
+ return codeActionForFix(context, sourceFile, symbolName, fix,
155243
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions());
155244
+ });
155231
155245
  },
155232
155246
  fixIds: [importFixId],
155233
155247
  getAllCodeActions: function (context) {
@@ -155252,10 +155266,10 @@ var ts;
155252
155266
  var newImports = new ts.Map();
155253
155267
  return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
155254
155268
  function addImportFromDiagnostic(diagnostic, context) {
155255
- var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
155256
- if (!info || !info.fixes.length)
155269
+ var info = getFixInfos(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
155270
+ if (!info || !info.length)
155257
155271
  return;
155258
- addImport(info);
155272
+ addImport(ts.first(info));
155259
155273
  }
155260
155274
  function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite) {
155261
155275
  var moduleSymbol = ts.Debug.checkDefined(exportedSymbol.parent);
@@ -155266,13 +155280,12 @@ var ts;
155266
155280
  var useRequire = shouldUseRequire(sourceFile, program);
155267
155281
  var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
155268
155282
  if (fix) {
155269
- addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
155283
+ addImport({ fix: fix, symbolName: symbolName, errorIdentifierText: undefined });
155270
155284
  }
155271
155285
  }
155272
155286
  function addImport(info) {
155273
155287
  var _a, _b;
155274
- var fixes = info.fixes, symbolName = info.symbolName;
155275
- var fix = ts.first(fixes);
155288
+ var fix = info.fix, symbolName = info.symbolName;
155276
155289
  switch (fix.kind) {
155277
155290
  case 0 /* UseNamespace */:
155278
155291
  addToNamespace.push(fix);
@@ -155456,7 +155469,7 @@ var ts;
155456
155469
  codefix.getImportCompletionAction = getImportCompletionAction;
155457
155470
  function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
155458
155471
  var compilerOptions = program.getCompilerOptions();
155459
- var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
155472
+ var symbolName = ts.single(getSymbolNamesToImport(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions));
155460
155473
  var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
155461
155474
  var includeSymbolNameInDescription = symbolName !== symbolToken.text;
155462
155475
  return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
@@ -155761,7 +155774,7 @@ var ts;
155761
155774
  return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire };
155762
155775
  }
155763
155776
  }
155764
- function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
155777
+ function getFixInfos(context, errorCode, pos, useAutoImportProvider) {
155765
155778
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
155766
155779
  var info;
155767
155780
  if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
@@ -155771,19 +155784,23 @@ var ts;
155771
155784
  return undefined;
155772
155785
  }
155773
155786
  else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
155774
- var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
155787
+ var symbolName_1 = ts.single(getSymbolNamesToImport(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions()));
155775
155788
  var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
155776
- return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
155789
+ return fix && [{ fix: fix, symbolName: symbolName_1, errorIdentifierText: symbolToken.text }];
155777
155790
  }
155778
155791
  else {
155779
155792
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
155780
155793
  }
155781
155794
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
155782
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
155795
+ return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host);
155783
155796
  }
155784
- function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
155797
+ function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host) {
155785
155798
  var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
155786
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
155799
+ return ts.sort(fixes, function (a, b) {
155800
+ return ts.compareBooleans(!!a.isJsxNamespaceFix, !!b.isJsxNamespaceFix) ||
155801
+ ts.compareValues(a.fix.kind, b.fix.kind) ||
155802
+ compareModuleSpecifiers(a.fix, b.fix, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath);
155803
+ });
155787
155804
  }
155788
155805
  function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
155789
155806
  if (!ts.some(fixes))
@@ -155834,7 +155851,6 @@ var ts;
155834
155851
  return 0 /* EqualTo */;
155835
155852
  }
155836
155853
  function getFixesInfoForUMDImport(_a, token) {
155837
- var _b;
155838
155854
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
155839
155855
  var checker = program.getTypeChecker();
155840
155856
  var umdSymbol = getUmdSymbol(token, checker);
@@ -155846,7 +155862,7 @@ var ts;
155846
155862
  var useRequire = shouldUseRequire(sourceFile, program);
155847
155863
  var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
155848
155864
  var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
155849
- return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
155865
+ return fixes.map(function (fix) { var _a; return ({ fix: fix, symbolName: symbolName, errorIdentifierText: (_a = ts.tryCast(token, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text }); });
155850
155866
  }
155851
155867
  function getUmdSymbol(token, checker) {
155852
155868
  // try the identifier to see if it is the umd symbol
@@ -155907,19 +155923,20 @@ var ts;
155907
155923
  var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences;
155908
155924
  var checker = program.getTypeChecker();
155909
155925
  var compilerOptions = program.getCompilerOptions();
155910
- var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions);
155911
- // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
155912
- if (symbolName === "default" /* Default */) {
155913
- return undefined;
155914
- }
155915
- var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
155916
- var useRequire = shouldUseRequire(sourceFile, program);
155917
- var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
155918
- var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
155919
- var _ = _a[0], exportInfos = _a[1];
155920
- return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
155921
- }));
155922
- return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
155926
+ return ts.flatMap(getSymbolNamesToImport(sourceFile, checker, symbolToken, compilerOptions), function (symbolName) {
155927
+ // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
155928
+ if (symbolName === "default" /* Default */) {
155929
+ return undefined;
155930
+ }
155931
+ var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
155932
+ var useRequire = shouldUseRequire(sourceFile, program);
155933
+ var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
155934
+ var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
155935
+ var _ = _a[0], exportInfos = _a[1];
155936
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
155937
+ }));
155938
+ return fixes.map(function (fix) { return ({ fix: fix, symbolName: symbolName, errorIdentifierText: symbolToken.text, isJsxNamespaceFix: symbolName !== symbolToken.text }); });
155939
+ });
155923
155940
  }
155924
155941
  function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
155925
155942
  var checker = program.getTypeChecker();
@@ -155931,15 +155948,16 @@ var ts;
155931
155948
  return undefined;
155932
155949
  return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
155933
155950
  }
155934
- function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
155951
+ function getSymbolNamesToImport(sourceFile, checker, symbolToken, compilerOptions) {
155935
155952
  var parent = symbolToken.parent;
155936
155953
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
155937
155954
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
155938
155955
  if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
155939
- return jsxNamespace;
155956
+ var needsComponentNameFix = !ts.isIntrinsicJsxName(symbolToken.text) && !checker.resolveName(symbolToken.text, symbolToken, 111551 /* Value */, /*excludeGlobals*/ false);
155957
+ return needsComponentNameFix ? [symbolToken.text, jsxNamespace] : [jsxNamespace];
155940
155958
  }
155941
155959
  }
155942
- return symbolToken.text;
155960
+ return [symbolToken.text];
155943
155961
  }
155944
155962
  function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
155945
155963
  if (ts.isIntrinsicJsxName(symbolToken.text))
@@ -160148,23 +160166,36 @@ var ts;
160148
160166
  * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
160149
160167
  */
160150
160168
  function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) {
160169
+ var _a;
160151
160170
  if (preserveOptional === void 0) { preserveOptional = 3 /* All */; }
160152
160171
  if (isAmbient === void 0) { isAmbient = false; }
160153
160172
  var declarations = symbol.getDeclarations();
160154
- if (!(declarations && declarations.length)) {
160155
- return undefined;
160156
- }
160173
+ var declaration = declarations === null || declarations === void 0 ? void 0 : declarations[0];
160157
160174
  var checker = context.program.getTypeChecker();
160158
160175
  var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions());
160159
- var declaration = declarations[0];
160176
+ /**
160177
+ * (#49811)
160178
+ * Note that there are cases in which the symbol declaration is not present. For example, in the code below both
160179
+ * `MappedIndirect.ax` and `MappedIndirect.ay` have no declaration node attached (due to their mapped-type
160180
+ * parent):
160181
+ *
160182
+ * >>> ```ts
160183
+ * >>> type Base = { ax: number; ay: string };
160184
+ * >>> type BaseKeys = keyof Base;
160185
+ * >>> type MappedIndirect = { [K in BaseKeys]: boolean };
160186
+ * >>> ```
160187
+ *
160188
+ * In such cases, we assume the declaration to be a `PropertySignature`.
160189
+ */
160190
+ var kind = (_a = declaration === null || declaration === void 0 ? void 0 : declaration.kind) !== null && _a !== void 0 ? _a : 166 /* PropertySignature */;
160160
160191
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
160161
- var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration));
160192
+ var visibilityModifier = createVisibilityModifier(declaration ? ts.getEffectiveModifierFlags(declaration) : 0 /* None */);
160162
160193
  var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
160163
160194
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
160164
160195
  var optional = !!(symbol.flags & 16777216 /* Optional */);
160165
160196
  var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
160166
160197
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
160167
- switch (declaration.kind) {
160198
+ switch (kind) {
160168
160199
  case 166 /* PropertySignature */:
160169
160200
  case 167 /* PropertyDeclaration */:
160170
160201
  var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
@@ -160176,11 +160207,12 @@ var ts;
160176
160207
  importSymbols(importAdder, importableReference.symbols);
160177
160208
  }
160178
160209
  }
160179
- addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
160210
+ addClassElement(ts.factory.createPropertyDeclaration(modifiers, declaration ? name : symbol.getName(), optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
160180
160211
  /*initializer*/ undefined));
160181
160212
  break;
160182
160213
  case 172 /* GetAccessor */:
160183
160214
  case 173 /* SetAccessor */: {
160215
+ ts.Debug.assertIsDefined(declarations);
160184
160216
  var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
160185
160217
  var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration);
160186
160218
  var orderedAccessors = allAccessors.secondAccessor
@@ -160216,6 +160248,7 @@ var ts;
160216
160248
  // If there is more than one overload but no implementation signature
160217
160249
  // (eg: an abstract method or interface declaration), there is a 1-1
160218
160250
  // correspondence of declarations and signatures.
160251
+ ts.Debug.assertIsDefined(declarations);
160219
160252
  var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
160220
160253
  if (!ts.some(signatures)) {
160221
160254
  break;
@@ -160226,8 +160259,8 @@ var ts;
160226
160259
  outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
160227
160260
  break;
160228
160261
  }
160229
- for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
160230
- var signature = signatures_1[_a];
160262
+ for (var _b = 0, signatures_1 = signatures; _b < signatures_1.length; _b++) {
160263
+ var signature = signatures_1[_b];
160231
160264
  // Ensure nodes are fresh so they can have different positions when going through formatting.
160232
160265
  outputMethod(quotePreference, signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false));
160233
160266
  }