typescript 4.9.0-dev.20220815 → 4.9.0-dev.20220818

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.
@@ -99,7 +99,7 @@ var ts;
99
99
  // The following is baselined as a literal template type without intervention
100
100
  /** The version of the TypeScript compiler release */
101
101
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
102
- ts.version = ts.versionMajorMinor + ".0-dev.20220815";
102
+ ts.version = ts.versionMajorMinor + ".0-dev.20220818";
103
103
  /* @internal */
104
104
  var Comparison;
105
105
  (function (Comparison) {
@@ -1153,6 +1153,13 @@ var ts;
1153
1153
  : undefined;
1154
1154
  }
1155
1155
  ts.singleOrUndefined = singleOrUndefined;
1156
+ /**
1157
+ * Returns the only element of an array if it contains only one element; throws otherwise.
1158
+ */
1159
+ function single(array) {
1160
+ return ts.Debug.checkDefined(singleOrUndefined(array));
1161
+ }
1162
+ ts.single = single;
1156
1163
  function singleOrMany(array) {
1157
1164
  return array && array.length === 1
1158
1165
  ? array[0]
@@ -7020,7 +7027,6 @@ var ts;
7020
7027
  // not actually work.
7021
7028
  var byteOrderMarkIndicator = "\uFEFF";
7022
7029
  function getNodeSystem() {
7023
- var _a;
7024
7030
  var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
7025
7031
  var _fs = require("fs");
7026
7032
  var _path = require("path");
@@ -7030,7 +7036,7 @@ var ts;
7030
7036
  try {
7031
7037
  _crypto = require("crypto");
7032
7038
  }
7033
- catch (_b) {
7039
+ catch (_a) {
7034
7040
  _crypto = undefined;
7035
7041
  }
7036
7042
  var activeSession;
@@ -7041,10 +7047,10 @@ var ts;
7041
7047
  var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
7042
7048
  var platform = _os.platform();
7043
7049
  var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
7044
- var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync;
7050
+ var fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
7045
7051
  var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
7046
7052
  var getCurrentDirectory = ts.memoize(function () { return process.cwd(); });
7047
- var _c = createSystemWatchFunctions({
7053
+ var _b = createSystemWatchFunctions({
7048
7054
  pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
7049
7055
  getModifiedTime: getModifiedTime,
7050
7056
  setTimeout: setTimeout,
@@ -7064,7 +7070,7 @@ var ts;
7064
7070
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7065
7071
  inodeWatching: isLinuxOrMacOs,
7066
7072
  sysLog: sysLog,
7067
- }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
7073
+ }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
7068
7074
  var nodeSystem = {
7069
7075
  args: process.argv.slice(2),
7070
7076
  newLine: _os.EOL,
@@ -7457,9 +7463,12 @@ var ts;
7457
7463
  function getDirectories(path) {
7458
7464
  return getAccessibleFileSystemEntries(path).directories.slice();
7459
7465
  }
7466
+ function fsRealPathHandlingLongPath(path) {
7467
+ return path.length < 260 ? _fs.realpathSync.native(path) : _fs.realpathSync(path);
7468
+ }
7460
7469
  function realpath(path) {
7461
7470
  try {
7462
- return realpathSync(path);
7471
+ return fsRealpath(path);
7463
7472
  }
7464
7473
  catch (_a) {
7465
7474
  return path;
@@ -8889,7 +8898,7 @@ var ts;
8889
8898
  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."),
8890
8899
  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."),
8891
8900
  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."),
8892
- 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."),
8901
+ 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."),
8893
8902
  _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."),
8894
8903
  _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."),
8895
8904
  _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."),
@@ -18116,7 +18125,7 @@ var ts;
18116
18125
  }
18117
18126
  diagnostics = nonFileDiagnostics;
18118
18127
  }
18119
- ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
18128
+ ts.insertSorted(diagnostics, diagnostic, compareDiagnosticsSkipRelatedInformation);
18120
18129
  }
18121
18130
  function getGlobalDiagnostics() {
18122
18131
  hasReadNonFileDiagnostics = true;
@@ -51043,7 +51052,7 @@ var ts;
51043
51052
  var exportAssignment = exportEqualsSymbol.valueDeclaration;
51044
51053
  var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
51045
51054
  if (exportAssignment) {
51046
- 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));
51055
+ 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));
51047
51056
  }
51048
51057
  }
51049
51058
  else {
@@ -65716,7 +65725,8 @@ var ts;
65716
65725
  return 0 /* False */;
65717
65726
  }
65718
65727
  }
65719
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
65728
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || relation === comparableRelation && isLiteralType(source)) &&
65729
+ !(intersectionState & 2 /* Target */) &&
65720
65730
  source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
65721
65731
  target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
65722
65732
  (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
@@ -66493,7 +66503,7 @@ var ts;
66493
66503
  // create a new chain for the constraint error
66494
66504
  resetErrorInfo(saveErrorInfo);
66495
66505
  }
66496
- if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
66506
+ if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors, /* headMessage */ undefined, intersectionState)) {
66497
66507
  return result;
66498
66508
  }
66499
66509
  // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
@@ -68199,7 +68209,7 @@ var ts;
68199
68209
  if (!isLiteralOfContextualType(type, contextualType)) {
68200
68210
  type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
68201
68211
  }
68202
- return type;
68212
+ return getRegularTypeOfLiteralType(type);
68203
68213
  }
68204
68214
  function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
68205
68215
  if (type && isUnitType(type)) {
@@ -138902,6 +138912,8 @@ var ts;
138902
138912
  // Similarly, skip past the symbol for 'export ='
138903
138913
  if (importedSymbol.escapedName === "export=") {
138904
138914
  importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker);
138915
+ if (importedSymbol === undefined)
138916
+ return undefined;
138905
138917
  }
138906
138918
  // If the import has a different name than the export, do not continue searching.
138907
138919
  // If `importedName` is undefined, do continue searching as the export is anonymous.
@@ -138923,19 +138935,19 @@ var ts;
138923
138935
  FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol;
138924
138936
  function getExportEqualsLocalSymbol(importedSymbol, checker) {
138925
138937
  if (importedSymbol.flags & 2097152 /* Alias */) {
138926
- return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol));
138938
+ return checker.getImmediateAliasedSymbol(importedSymbol);
138927
138939
  }
138928
138940
  var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration);
138929
138941
  if (ts.isExportAssignment(decl)) { // `export = class {}`
138930
- return ts.Debug.checkDefined(decl.expression.symbol);
138942
+ return decl.expression.symbol;
138931
138943
  }
138932
138944
  else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}`
138933
- return ts.Debug.checkDefined(decl.right.symbol);
138945
+ return decl.right.symbol;
138934
138946
  }
138935
138947
  else if (ts.isSourceFile(decl)) { // json module
138936
- return ts.Debug.checkDefined(decl.symbol);
138948
+ return decl.symbol;
138937
138949
  }
138938
- return ts.Debug.fail();
138950
+ return undefined;
138939
138951
  }
138940
138952
  // If a reference is a class expression, the exported node would be its parent.
138941
138953
  // If a reference is a variable declaration, the exported node would be the variable statement.
@@ -155212,13 +155224,15 @@ var ts;
155212
155224
  errorCodes: errorCodes,
155213
155225
  getCodeActions: function (context) {
155214
155226
  var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span, program = context.program;
155215
- var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
155227
+ var info = getFixInfos(context, errorCode, span.start, /*useAutoImportProvider*/ true);
155216
155228
  if (!info)
155217
155229
  return undefined;
155218
- var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
155219
155230
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
155220
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
155221
- /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
155231
+ return info.map(function (_a) {
155232
+ var fix = _a.fix, symbolName = _a.symbolName, errorIdentifierText = _a.errorIdentifierText;
155233
+ return codeActionForFix(context, sourceFile, symbolName, fix,
155234
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions());
155235
+ });
155222
155236
  },
155223
155237
  fixIds: [importFixId],
155224
155238
  getAllCodeActions: function (context) {
@@ -155243,10 +155257,10 @@ var ts;
155243
155257
  var newImports = new ts.Map();
155244
155258
  return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
155245
155259
  function addImportFromDiagnostic(diagnostic, context) {
155246
- var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
155247
- if (!info || !info.fixes.length)
155260
+ var info = getFixInfos(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
155261
+ if (!info || !info.length)
155248
155262
  return;
155249
- addImport(info);
155263
+ addImport(ts.first(info));
155250
155264
  }
155251
155265
  function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite) {
155252
155266
  var moduleSymbol = ts.Debug.checkDefined(exportedSymbol.parent);
@@ -155257,13 +155271,12 @@ var ts;
155257
155271
  var useRequire = shouldUseRequire(sourceFile, program);
155258
155272
  var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
155259
155273
  if (fix) {
155260
- addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
155274
+ addImport({ fix: fix, symbolName: symbolName, errorIdentifierText: undefined });
155261
155275
  }
155262
155276
  }
155263
155277
  function addImport(info) {
155264
155278
  var _a, _b;
155265
- var fixes = info.fixes, symbolName = info.symbolName;
155266
- var fix = ts.first(fixes);
155279
+ var fix = info.fix, symbolName = info.symbolName;
155267
155280
  switch (fix.kind) {
155268
155281
  case 0 /* UseNamespace */:
155269
155282
  addToNamespace.push(fix);
@@ -155447,7 +155460,7 @@ var ts;
155447
155460
  codefix.getImportCompletionAction = getImportCompletionAction;
155448
155461
  function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
155449
155462
  var compilerOptions = program.getCompilerOptions();
155450
- var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
155463
+ var symbolName = ts.single(getSymbolNamesToImport(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions));
155451
155464
  var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
155452
155465
  var includeSymbolNameInDescription = symbolName !== symbolToken.text;
155453
155466
  return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
@@ -155752,7 +155765,7 @@ var ts;
155752
155765
  return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire };
155753
155766
  }
155754
155767
  }
155755
- function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
155768
+ function getFixInfos(context, errorCode, pos, useAutoImportProvider) {
155756
155769
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
155757
155770
  var info;
155758
155771
  if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
@@ -155762,19 +155775,23 @@ var ts;
155762
155775
  return undefined;
155763
155776
  }
155764
155777
  else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
155765
- var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
155778
+ var symbolName_1 = ts.single(getSymbolNamesToImport(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions()));
155766
155779
  var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
155767
- return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
155780
+ return fix && [{ fix: fix, symbolName: symbolName_1, errorIdentifierText: symbolToken.text }];
155768
155781
  }
155769
155782
  else {
155770
155783
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
155771
155784
  }
155772
155785
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
155773
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter, context.host) });
155786
+ return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host);
155774
155787
  }
155775
- function sortFixes(fixes, sourceFile, program, packageJsonImportFilter, host) {
155788
+ function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host) {
155776
155789
  var _toPath = function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); };
155777
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath); });
155790
+ return ts.sort(fixes, function (a, b) {
155791
+ return ts.compareBooleans(!!a.isJsxNamespaceFix, !!b.isJsxNamespaceFix) ||
155792
+ ts.compareValues(a.fix.kind, b.fix.kind) ||
155793
+ compareModuleSpecifiers(a.fix, b.fix, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath);
155794
+ });
155778
155795
  }
155779
155796
  function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
155780
155797
  if (!ts.some(fixes))
@@ -155825,7 +155842,6 @@ var ts;
155825
155842
  return 0 /* EqualTo */;
155826
155843
  }
155827
155844
  function getFixesInfoForUMDImport(_a, token) {
155828
- var _b;
155829
155845
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
155830
155846
  var checker = program.getTypeChecker();
155831
155847
  var umdSymbol = getUmdSymbol(token, checker);
@@ -155837,7 +155853,7 @@ var ts;
155837
155853
  var useRequire = shouldUseRequire(sourceFile, program);
155838
155854
  var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
155839
155855
  var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
155840
- return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
155856
+ 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 }); });
155841
155857
  }
155842
155858
  function getUmdSymbol(token, checker) {
155843
155859
  // try the identifier to see if it is the umd symbol
@@ -155898,19 +155914,20 @@ var ts;
155898
155914
  var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences;
155899
155915
  var checker = program.getTypeChecker();
155900
155916
  var compilerOptions = program.getCompilerOptions();
155901
- var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions);
155902
- // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
155903
- if (symbolName === "default" /* Default */) {
155904
- return undefined;
155905
- }
155906
- var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
155907
- var useRequire = shouldUseRequire(sourceFile, program);
155908
- var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
155909
- var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
155910
- var _ = _a[0], exportInfos = _a[1];
155911
- return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
155912
- }));
155913
- return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
155917
+ return ts.flatMap(getSymbolNamesToImport(sourceFile, checker, symbolToken, compilerOptions), function (symbolName) {
155918
+ // "default" is a keyword and not a legal identifier for the import, but appears as an identifier.
155919
+ if (symbolName === "default" /* Default */) {
155920
+ return undefined;
155921
+ }
155922
+ var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
155923
+ var useRequire = shouldUseRequire(sourceFile, program);
155924
+ var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
155925
+ var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
155926
+ var _ = _a[0], exportInfos = _a[1];
155927
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
155928
+ }));
155929
+ return fixes.map(function (fix) { return ({ fix: fix, symbolName: symbolName, errorIdentifierText: symbolToken.text, isJsxNamespaceFix: symbolName !== symbolToken.text }); });
155930
+ });
155914
155931
  }
155915
155932
  function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
155916
155933
  var checker = program.getTypeChecker();
@@ -155922,15 +155939,16 @@ var ts;
155922
155939
  return undefined;
155923
155940
  return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
155924
155941
  }
155925
- function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
155942
+ function getSymbolNamesToImport(sourceFile, checker, symbolToken, compilerOptions) {
155926
155943
  var parent = symbolToken.parent;
155927
155944
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
155928
155945
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
155929
155946
  if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
155930
- return jsxNamespace;
155947
+ var needsComponentNameFix = !ts.isIntrinsicJsxName(symbolToken.text) && !checker.resolveName(symbolToken.text, symbolToken, 111551 /* Value */, /*excludeGlobals*/ false);
155948
+ return needsComponentNameFix ? [symbolToken.text, jsxNamespace] : [jsxNamespace];
155931
155949
  }
155932
155950
  }
155933
- return symbolToken.text;
155951
+ return [symbolToken.text];
155934
155952
  }
155935
155953
  function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
155936
155954
  if (ts.isIntrinsicJsxName(symbolToken.text))
@@ -160139,23 +160157,36 @@ var ts;
160139
160157
  * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
160140
160158
  */
160141
160159
  function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) {
160160
+ var _a;
160142
160161
  if (preserveOptional === void 0) { preserveOptional = 3 /* All */; }
160143
160162
  if (isAmbient === void 0) { isAmbient = false; }
160144
160163
  var declarations = symbol.getDeclarations();
160145
- if (!(declarations && declarations.length)) {
160146
- return undefined;
160147
- }
160164
+ var declaration = declarations === null || declarations === void 0 ? void 0 : declarations[0];
160148
160165
  var checker = context.program.getTypeChecker();
160149
160166
  var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions());
160150
- var declaration = declarations[0];
160167
+ /**
160168
+ * (#49811)
160169
+ * Note that there are cases in which the symbol declaration is not present. For example, in the code below both
160170
+ * `MappedIndirect.ax` and `MappedIndirect.ay` have no declaration node attached (due to their mapped-type
160171
+ * parent):
160172
+ *
160173
+ * >>> ```ts
160174
+ * >>> type Base = { ax: number; ay: string };
160175
+ * >>> type BaseKeys = keyof Base;
160176
+ * >>> type MappedIndirect = { [K in BaseKeys]: boolean };
160177
+ * >>> ```
160178
+ *
160179
+ * In such cases, we assume the declaration to be a `PropertySignature`.
160180
+ */
160181
+ var kind = (_a = declaration === null || declaration === void 0 ? void 0 : declaration.kind) !== null && _a !== void 0 ? _a : 166 /* PropertySignature */;
160151
160182
  var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
160152
- var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration));
160183
+ var visibilityModifier = createVisibilityModifier(declaration ? ts.getEffectiveModifierFlags(declaration) : 0 /* None */);
160153
160184
  var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
160154
160185
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
160155
160186
  var optional = !!(symbol.flags & 16777216 /* Optional */);
160156
160187
  var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
160157
160188
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
160158
- switch (declaration.kind) {
160189
+ switch (kind) {
160159
160190
  case 166 /* PropertySignature */:
160160
160191
  case 167 /* PropertyDeclaration */:
160161
160192
  var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
@@ -160167,11 +160198,12 @@ var ts;
160167
160198
  importSymbols(importAdder, importableReference.symbols);
160168
160199
  }
160169
160200
  }
160170
- addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
160201
+ addClassElement(ts.factory.createPropertyDeclaration(modifiers, declaration ? name : symbol.getName(), optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
160171
160202
  /*initializer*/ undefined));
160172
160203
  break;
160173
160204
  case 172 /* GetAccessor */:
160174
160205
  case 173 /* SetAccessor */: {
160206
+ ts.Debug.assertIsDefined(declarations);
160175
160207
  var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
160176
160208
  var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration);
160177
160209
  var orderedAccessors = allAccessors.secondAccessor
@@ -160207,6 +160239,7 @@ var ts;
160207
160239
  // If there is more than one overload but no implementation signature
160208
160240
  // (eg: an abstract method or interface declaration), there is a 1-1
160209
160241
  // correspondence of declarations and signatures.
160242
+ ts.Debug.assertIsDefined(declarations);
160210
160243
  var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures();
160211
160244
  if (!ts.some(signatures)) {
160212
160245
  break;
@@ -160217,8 +160250,8 @@ var ts;
160217
160250
  outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
160218
160251
  break;
160219
160252
  }
160220
- for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
160221
- var signature = signatures_1[_a];
160253
+ for (var _b = 0, signatures_1 = signatures; _b < signatures_1.length; _b++) {
160254
+ var signature = signatures_1[_b];
160222
160255
  // Ensure nodes are fresh so they can have different positions when going through formatting.
160223
160256
  outputMethod(quotePreference, signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false));
160224
160257
  }
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220815";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220818";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -1143,6 +1143,13 @@ var ts;
1143
1143
  : undefined;
1144
1144
  }
1145
1145
  ts.singleOrUndefined = singleOrUndefined;
1146
+ /**
1147
+ * Returns the only element of an array if it contains only one element; throws otherwise.
1148
+ */
1149
+ function single(array) {
1150
+ return ts.Debug.checkDefined(singleOrUndefined(array));
1151
+ }
1152
+ ts.single = single;
1146
1153
  function singleOrMany(array) {
1147
1154
  return array && array.length === 1
1148
1155
  ? array[0]
@@ -7010,7 +7017,6 @@ var ts;
7010
7017
  // not actually work.
7011
7018
  var byteOrderMarkIndicator = "\uFEFF";
7012
7019
  function getNodeSystem() {
7013
- var _a;
7014
7020
  var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
7015
7021
  var _fs = require("fs");
7016
7022
  var _path = require("path");
@@ -7020,7 +7026,7 @@ var ts;
7020
7026
  try {
7021
7027
  _crypto = require("crypto");
7022
7028
  }
7023
- catch (_b) {
7029
+ catch (_a) {
7024
7030
  _crypto = undefined;
7025
7031
  }
7026
7032
  var activeSession;
@@ -7031,10 +7037,10 @@ var ts;
7031
7037
  var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
7032
7038
  var platform = _os.platform();
7033
7039
  var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
7034
- var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync;
7040
+ var fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
7035
7041
  var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
7036
7042
  var getCurrentDirectory = ts.memoize(function () { return process.cwd(); });
7037
- var _c = createSystemWatchFunctions({
7043
+ var _b = createSystemWatchFunctions({
7038
7044
  pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
7039
7045
  getModifiedTime: getModifiedTime,
7040
7046
  setTimeout: setTimeout,
@@ -7054,7 +7060,7 @@ var ts;
7054
7060
  defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
7055
7061
  inodeWatching: isLinuxOrMacOs,
7056
7062
  sysLog: sysLog,
7057
- }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
7063
+ }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
7058
7064
  var nodeSystem = {
7059
7065
  args: process.argv.slice(2),
7060
7066
  newLine: _os.EOL,
@@ -7447,9 +7453,12 @@ var ts;
7447
7453
  function getDirectories(path) {
7448
7454
  return getAccessibleFileSystemEntries(path).directories.slice();
7449
7455
  }
7456
+ function fsRealPathHandlingLongPath(path) {
7457
+ return path.length < 260 ? _fs.realpathSync.native(path) : _fs.realpathSync(path);
7458
+ }
7450
7459
  function realpath(path) {
7451
7460
  try {
7452
- return realpathSync(path);
7461
+ return fsRealpath(path);
7453
7462
  }
7454
7463
  catch (_a) {
7455
7464
  return path;
@@ -8879,7 +8888,7 @@ var ts;
8879
8888
  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."),
8880
8889
  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."),
8881
8890
  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."),
8882
- 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."),
8891
+ 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."),
8883
8892
  _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."),
8884
8893
  _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."),
8885
8894
  _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."),
@@ -18106,7 +18115,7 @@ var ts;
18106
18115
  }
18107
18116
  diagnostics = nonFileDiagnostics;
18108
18117
  }
18109
- ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
18118
+ ts.insertSorted(diagnostics, diagnostic, compareDiagnosticsSkipRelatedInformation);
18110
18119
  }
18111
18120
  function getGlobalDiagnostics() {
18112
18121
  hasReadNonFileDiagnostics = true;
@@ -51033,7 +51042,7 @@ var ts;
51033
51042
  var exportAssignment = exportEqualsSymbol.valueDeclaration;
51034
51043
  var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
51035
51044
  if (exportAssignment) {
51036
- 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));
51045
+ 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));
51037
51046
  }
51038
51047
  }
51039
51048
  else {
@@ -65706,7 +65715,8 @@ var ts;
65706
65715
  return 0 /* False */;
65707
65716
  }
65708
65717
  }
65709
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
65718
+ var isPerformingCommonPropertyChecks = (relation !== comparableRelation || relation === comparableRelation && isLiteralType(source)) &&
65719
+ !(intersectionState & 2 /* Target */) &&
65710
65720
  source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
65711
65721
  target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
65712
65722
  (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
@@ -66483,7 +66493,7 @@ var ts;
66483
66493
  // create a new chain for the constraint error
66484
66494
  resetErrorInfo(saveErrorInfo);
66485
66495
  }
66486
- if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
66496
+ if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors, /* headMessage */ undefined, intersectionState)) {
66487
66497
  return result;
66488
66498
  }
66489
66499
  // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
@@ -68189,7 +68199,7 @@ var ts;
68189
68199
  if (!isLiteralOfContextualType(type, contextualType)) {
68190
68200
  type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
68191
68201
  }
68192
- return type;
68202
+ return getRegularTypeOfLiteralType(type);
68193
68203
  }
68194
68204
  function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
68195
68205
  if (type && isUnitType(type)) {
@@ -1493,7 +1493,7 @@
1493
1493
  "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114": "此成员必须有 \"override\" 修饰符,因为它替代基类 \"{0}\" 中的一个成员。",
1494
1494
  "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116": "此成员必须有 \"override\" 修饰符,因为它替代基类 \"{0}\" 中声明的一个抽象方法。",
1495
1495
  "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "只能通过启用 \"{0}\" 标志并引用其默认导出,使用 ECMAScript 导入/导出来引用此模块。",
1496
- "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "此模块是使用 \"export =\" 声明的,只能在使用 \"{0}\" 标志时进行默认导入。",
1496
+ "This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag_2594": "此模块是使用 “export =” 声明的,只能在使用“{0}”标志时用于默认导入。",
1497
1497
  "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394": "此重载签名与其实现签名不兼容。",
1498
1498
  "This_parameter_is_not_allowed_with_use_strict_directive_1346": "此参数不允许与 \"use strict\" 指令一起使用。",
1499
1499
  "This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_4120": "此参数属性必须具有带 “@override” 标记的 JSDoc 注释,因为它将替代基类“{0}”中的成员。",
@@ -1493,7 +1493,7 @@
1493
1493
  "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114": "因為此成員會覆寫基底類別 '{0}' 中的成員,所以其必須具有 'override' 修飾元。",
1494
1494
  "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116": "因為此成員會覆寫基底類別 '{0}' 中宣告的抽象方法,所以其必須具有 'override' 修飾元。",
1495
1495
  "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "只能以 ECMAScript 匯入/匯出來參考此模組,方法為開啟 '{0}' 旗標並參考其預設匯出。",
1496
- "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "此模組使用 'export =' 宣告,只能在使用 '{0}' 旗標時搭配預設匯入使用。",
1496
+ "This_module_is_declared_with_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag_2594": "此模組使用 'export =' 宣告,只能在使用 '{0}' 旗標時搭配預設匯入使用。",
1497
1497
  "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394": "此多載簽章與其實作簽章不相容。",
1498
1498
  "This_parameter_is_not_allowed_with_use_strict_directive_1346": "不允許此參數搭配 'use strict' 指示詞使用。",
1499
1499
  "This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_4120": "此參數屬性必須包含具有 '@override' 標籤的 JSDoc 註解,因為其會覆寫基底類別 '{0}' 中的成員。",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.9.0-dev.20220815",
5
+ "version": "4.9.0-dev.20220818",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@octokit/rest": "latest",
33
+ "@types/async": "latest",
33
34
  "@types/chai": "latest",
34
35
  "@types/convert-source-map": "latest",
35
36
  "@types/fs-extra": "^9.0.13",
@@ -88,6 +89,7 @@
88
89
  "typescript": "^4.5.5",
89
90
  "vinyl": "latest",
90
91
  "vinyl-sourcemaps-apply": "latest",
92
+ "which": "^2.0.2",
91
93
  "xml2js": "^0.4.23"
92
94
  },
93
95
  "overrides": {