@typescript-deploys/pr-build 4.6.0-pr-47126-8 → 4.6.0-pr-47400-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220107";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220113";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -2250,14 +2250,6 @@ var ts;
2250
2250
  }
2251
2251
  return s.slice(0, end + 1);
2252
2252
  }
2253
- function startWhitespaceCount(s) {
2254
- for (var i = 0; i < s.length; i++) {
2255
- if (!ts.isWhiteSpaceLike(s.charCodeAt(i)))
2256
- return i;
2257
- }
2258
- return s.length;
2259
- }
2260
- ts.startWhitespaceCount = startWhitespaceCount;
2261
2253
  })(ts || (ts = {}));
2262
2254
  /* @internal */
2263
2255
  var ts;
@@ -8600,12 +8592,12 @@ var ts;
8600
8592
  Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."),
8601
8593
  Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
8602
8594
  Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"),
8603
- _0_is_declared_here_Colon: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_Colon_2728", "'{0}' is declared here:"),
8595
+ _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
8604
8596
  Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."),
8605
8597
  An_arrow_function_cannot_have_a_this_parameter: diag(2730, ts.DiagnosticCategory.Error, "An_arrow_function_cannot_have_a_this_parameter_2730", "An arrow function cannot have a 'this' parameter."),
8606
8598
  Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."),
8607
8599
  Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension."),
8608
- Property_0_was_also_declared_here_Colon: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_Colon_2733", "Property '{0}' was also declared here:"),
8600
+ Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
8609
8601
  Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
8610
8602
  Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"),
8611
8603
  Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."),
@@ -9036,7 +9028,7 @@ var ts;
9036
9028
  Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"),
9037
9029
  Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
9038
9030
  Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
9039
- _0_was_also_declared_here_Colon: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_Colon_6203", "'{0}' was also declared here:"),
9031
+ _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
9040
9032
  and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
9041
9033
  All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."),
9042
9034
  package_json_has_a_typesVersions_field_with_version_specific_path_mappings: diag(6206, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206", "'package.json' has a 'typesVersions' field with version-specific path mappings."),
@@ -19799,16 +19791,6 @@ var ts;
19799
19791
  (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
19800
19792
  }
19801
19793
  },
19802
- setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) {
19803
- this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real);
19804
- var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1];
19805
- if (commonResolved && commonOriginal) {
19806
- this.setSymlinkedDirectory(commonOriginal, {
19807
- real: commonResolved,
19808
- realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName),
19809
- });
19810
- }
19811
- },
19812
19794
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
19813
19795
  var _this = this;
19814
19796
  var _a;
@@ -20776,9 +20758,40 @@ var ts;
20776
20758
  }
20777
20759
  ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
20778
20760
  function escapeSnippetText(text) {
20779
- return text.replace(/\$/gm, "\\$");
20761
+ return text.replace(/\$/gm, function () { return "\\$"; });
20780
20762
  }
20781
20763
  ts.escapeSnippetText = escapeSnippetText;
20764
+ function isNumericLiteralName(name) {
20765
+ // The intent of numeric names is that
20766
+ // - they are names with text in a numeric form, and that
20767
+ // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
20768
+ // acquired by applying the abstract 'ToNumber' operation on the name's text.
20769
+ //
20770
+ // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
20771
+ // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
20772
+ //
20773
+ // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
20774
+ // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
20775
+ // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
20776
+ // because their 'ToString' representation is not equal to their original text.
20777
+ // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
20778
+ //
20779
+ // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
20780
+ // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
20781
+ // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
20782
+ //
20783
+ // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
20784
+ // This is desired behavior, because when indexing with them as numeric entities, you are indexing
20785
+ // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
20786
+ return (+name).toString() === name;
20787
+ }
20788
+ ts.isNumericLiteralName = isNumericLiteralName;
20789
+ function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed) {
20790
+ return ts.isIdentifierText(name, target) ? ts.factory.createIdentifier(name) :
20791
+ !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
20792
+ ts.factory.createStringLiteral(name, !!singleQuote);
20793
+ }
20794
+ ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
20782
20795
  function isThisTypeParameter(type) {
20783
20796
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
20784
20797
  }
@@ -41486,9 +41499,7 @@ var ts;
41486
41499
  }
41487
41500
  }
41488
41501
  var failedLookupLocations = [];
41489
- var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41490
- ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41491
- NodeResolutionFeatures.None;
41502
+ var features = getDefaultNodeResolutionFeatures(options);
41492
41503
  var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41493
41504
  var resolved = primaryLookup();
41494
41505
  var primary = true;
@@ -41573,6 +41584,34 @@ var ts;
41573
41584
  }
41574
41585
  }
41575
41586
  ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
41587
+ function getDefaultNodeResolutionFeatures(options) {
41588
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
41589
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
41590
+ NodeResolutionFeatures.None;
41591
+ }
41592
+ /**
41593
+ * @internal
41594
+ * Does not try `@types/${packageName}` - use a second pass if needed.
41595
+ */
41596
+ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
41597
+ var moduleResolutionState = {
41598
+ compilerOptions: options,
41599
+ host: host,
41600
+ traceEnabled: isTraceEnabled(options, host),
41601
+ failedLookupLocations: [],
41602
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
41603
+ conditions: ts.emptyArray,
41604
+ features: NodeResolutionFeatures.None,
41605
+ };
41606
+ return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
41607
+ if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
41608
+ var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
41609
+ var candidate = ts.combinePaths(nodeModulesFolder, packageName);
41610
+ return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
41611
+ }
41612
+ });
41613
+ }
41614
+ ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
41576
41615
  /**
41577
41616
  * Given a set of options, returns the set of type directive names
41578
41617
  * that should be included for this program automatically.
@@ -42146,11 +42185,6 @@ var ts;
42146
42185
  }
42147
42186
  ts.resolveJSModule = resolveJSModule;
42148
42187
  /* @internal */
42149
- function tryResolveJSModule(moduleName, initialDir, host) {
42150
- return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
42151
- }
42152
- ts.tryResolveJSModule = tryResolveJSModule;
42153
- /* @internal */
42154
42188
  var NodeResolutionFeatures;
42155
42189
  (function (NodeResolutionFeatures) {
42156
42190
  NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
@@ -42458,6 +42492,97 @@ var ts;
42458
42492
  var versionPaths = packageInfo && packageInfo.versionPaths;
42459
42493
  return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
42460
42494
  }
42495
+ /* @internal */
42496
+ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
42497
+ if (!resolveJs && packageJsonInfo.resolvedEntrypoints !== undefined) {
42498
+ // Cached value excludes resolutions to JS files - those could be
42499
+ // cached separately, but they're used rarely.
42500
+ return packageJsonInfo.resolvedEntrypoints;
42501
+ }
42502
+ var entrypoints;
42503
+ var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
42504
+ var features = getDefaultNodeResolutionFeatures(options);
42505
+ var requireState = {
42506
+ compilerOptions: options,
42507
+ host: host,
42508
+ traceEnabled: isTraceEnabled(options, host),
42509
+ failedLookupLocations: [],
42510
+ packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42511
+ conditions: ["node", "require", "types"],
42512
+ features: features,
42513
+ };
42514
+ var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
42515
+ /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
42516
+ entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
42517
+ if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
42518
+ for (var _i = 0, _a = [["node", "import", "types"], ["node", "require", "types"]]; _i < _a.length; _i++) {
42519
+ var conditions = _a[_i];
42520
+ var exportState = __assign(__assign({}, requireState), { failedLookupLocations: [], conditions: conditions });
42521
+ var exportResolutions = loadEntrypointsFromExportMap(packageJsonInfo, packageJsonInfo.packageJsonContent.exports, exportState, extensions);
42522
+ if (exportResolutions) {
42523
+ for (var _b = 0, exportResolutions_1 = exportResolutions; _b < exportResolutions_1.length; _b++) {
42524
+ var resolution = exportResolutions_1[_b];
42525
+ entrypoints = ts.appendIfUnique(entrypoints, resolution.path);
42526
+ }
42527
+ }
42528
+ }
42529
+ }
42530
+ return packageJsonInfo.resolvedEntrypoints = entrypoints || false;
42531
+ }
42532
+ ts.getEntrypointsFromPackageJsonInfo = getEntrypointsFromPackageJsonInfo;
42533
+ function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
42534
+ var entrypoints;
42535
+ if (ts.isArray(exports)) {
42536
+ for (var _i = 0, exports_1 = exports; _i < exports_1.length; _i++) {
42537
+ var target = exports_1[_i];
42538
+ loadEntrypointsFromTargetExports(target);
42539
+ }
42540
+ }
42541
+ // eslint-disable-next-line no-null/no-null
42542
+ else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports)) {
42543
+ for (var key in exports) {
42544
+ loadEntrypointsFromTargetExports(exports[key]);
42545
+ }
42546
+ }
42547
+ else {
42548
+ loadEntrypointsFromTargetExports(exports);
42549
+ }
42550
+ return entrypoints;
42551
+ function loadEntrypointsFromTargetExports(target) {
42552
+ var _a, _b;
42553
+ if (typeof target === "string" && ts.startsWith(target, "./") && target.indexOf("*") === -1) {
42554
+ var partsAfterFirst = ts.getPathComponents(target).slice(2);
42555
+ if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
42556
+ return false;
42557
+ }
42558
+ var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
42559
+ var finalPath = ts.getNormalizedAbsolutePath(resolvedTarget, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
42560
+ var result = loadJSOrExactTSFileName(extensions, finalPath, /*recordOnlyFailures*/ false, state);
42561
+ if (result) {
42562
+ entrypoints = ts.appendIfUnique(entrypoints, result, function (a, b) { return a.path === b.path; });
42563
+ return true;
42564
+ }
42565
+ }
42566
+ else if (Array.isArray(target)) {
42567
+ for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
42568
+ var t = target_1[_i];
42569
+ var success = loadEntrypointsFromTargetExports(t);
42570
+ if (success) {
42571
+ return true;
42572
+ }
42573
+ }
42574
+ }
42575
+ // eslint-disable-next-line no-null/no-null
42576
+ else if (typeof target === "object" && target !== null) {
42577
+ return ts.forEach(ts.getOwnKeys(target), function (key) {
42578
+ if (key === "default" || ts.contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) {
42579
+ loadEntrypointsFromTargetExports(target[key]);
42580
+ return true;
42581
+ }
42582
+ });
42583
+ }
42584
+ }
42585
+ }
42461
42586
  /**
42462
42587
  * A function for locating the package.json scope for a given path
42463
42588
  */
@@ -42514,7 +42639,7 @@ var ts;
42514
42639
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
42515
42640
  }
42516
42641
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
42517
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
42642
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
42518
42643
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
42519
42644
  return result;
42520
42645
  }
@@ -42811,8 +42936,8 @@ var ts;
42811
42936
  }
42812
42937
  return toSearchResult(/*value*/ undefined);
42813
42938
  }
42814
- for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
42815
- var elem = target_1[_d];
42939
+ for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
42940
+ var elem = target_2[_d];
42816
42941
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
42817
42942
  if (result) {
42818
42943
  return result;
@@ -46851,6 +46976,7 @@ var ts;
46851
46976
  var location = ts.getParseTreeNode(locationIn);
46852
46977
  return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
46853
46978
  },
46979
+ getTypeOfSymbol: getTypeOfSymbol,
46854
46980
  getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
46855
46981
  var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
46856
46982
  if (parameter === undefined)
@@ -47735,7 +47861,7 @@ var ts;
47735
47861
  if (adjustedNode === errorNode)
47736
47862
  return "continue";
47737
47863
  err.relatedInformation = err.relatedInformation || [];
47738
- var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here_Colon, symbolName);
47864
+ var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
47739
47865
  var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
47740
47866
  if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; }))
47741
47867
  return "continue";
@@ -48479,7 +48605,7 @@ var ts;
48479
48605
  var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
48480
48606
  addErrorOrSuggestion(!isUncheckedJS, diagnostic);
48481
48607
  if (suggestion.valueDeclaration) {
48482
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestionName));
48608
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
48483
48609
  }
48484
48610
  }
48485
48611
  }
@@ -48807,7 +48933,7 @@ var ts;
48807
48933
  }
48808
48934
  }
48809
48935
  if (diagnosticMessage) {
48810
- ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here_Colon, declarationName));
48936
+ ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
48811
48937
  }
48812
48938
  }
48813
48939
  }
@@ -49132,7 +49258,7 @@ var ts;
49132
49258
  var suggestionName = symbolToString(suggestion);
49133
49259
  var diagnostic = error(name, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
49134
49260
  if (suggestion.valueDeclaration) {
49135
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestionName));
49261
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
49136
49262
  }
49137
49263
  }
49138
49264
  else {
@@ -49164,7 +49290,7 @@ var ts;
49164
49290
  error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
49165
49291
  if (localSymbol.declarations) {
49166
49292
  ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
49167
- return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here_Colon : ts.Diagnostics.and_here, declarationName);
49293
+ return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
49168
49294
  }), false));
49169
49295
  }
49170
49296
  }
@@ -49840,7 +49966,7 @@ var ts;
49840
49966
  if (!sigs || !sigs.length) {
49841
49967
  sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
49842
49968
  }
49843
- if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
49969
+ if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) {
49844
49970
  var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
49845
49971
  return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
49846
49972
  }
@@ -52044,8 +52170,8 @@ var ts;
52044
52170
  }
52045
52171
  else {
52046
52172
  if (parent && getExportsOfSymbol(parent)) {
52047
- var exports_1 = getExportsOfSymbol(parent);
52048
- ts.forEachEntry(exports_1, function (ex, name) {
52173
+ var exports_2 = getExportsOfSymbol(parent);
52174
+ ts.forEachEntry(exports_2, function (ex, name) {
52049
52175
  if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
52050
52176
  symbolName = ts.unescapeLeadingUnderscores(name);
52051
52177
  return true;
@@ -52206,7 +52332,7 @@ var ts;
52206
52332
  }
52207
52333
  var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
52208
52334
  var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
52209
- return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote);
52335
+ return ts.createPropertyNameNodeForIdentifierOrLiteral(rawName, ts.getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
52210
52336
  }
52211
52337
  // See getNameForSymbolFromNameType for a stringy equivalent
52212
52338
  function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
@@ -52214,24 +52340,19 @@ var ts;
52214
52340
  if (nameType) {
52215
52341
  if (nameType.flags & 384 /* StringOrNumberLiteral */) {
52216
52342
  var name = "" + nameType.value;
52217
- if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
52343
+ if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
52218
52344
  return ts.factory.createStringLiteral(name, !!singleQuote);
52219
52345
  }
52220
- if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
52346
+ if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
52221
52347
  return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
52222
52348
  }
52223
- return createPropertyNameNodeForIdentifierOrLiteral(name);
52349
+ return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
52224
52350
  }
52225
52351
  if (nameType.flags & 8192 /* UniqueESSymbol */) {
52226
52352
  return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
52227
52353
  }
52228
52354
  }
52229
52355
  }
52230
- function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
52231
- return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
52232
- !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
52233
- ts.factory.createStringLiteral(name, !!singleQuote);
52234
- }
52235
52356
  function cloneNodeBuilderContext(context) {
52236
52357
  var initial = __assign({}, context);
52237
52358
  // Make type parameters created within this context not consume the name outside this context
@@ -53747,10 +53868,10 @@ var ts;
53747
53868
  if (nameType) {
53748
53869
  if (nameType.flags & 384 /* StringOrNumberLiteral */) {
53749
53870
  var name = "" + nameType.value;
53750
- if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
53871
+ if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
53751
53872
  return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
53752
53873
  }
53753
- if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
53874
+ if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
53754
53875
  return "[" + name + "]";
53755
53876
  }
53756
53877
  return name;
@@ -54667,8 +54788,8 @@ var ts;
54667
54788
  if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
54668
54789
  var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
54669
54790
  var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
54670
- ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here_Colon, unescapedName));
54671
- ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here_Colon, unescapedName));
54791
+ ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
54792
+ ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
54672
54793
  }
54673
54794
  var union = createSymbol(s.flags | exportedMember.flags, name);
54674
54795
  union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
@@ -56130,7 +56251,7 @@ var ts;
56130
56251
  // report an error at each declaration.
56131
56252
  var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
56132
56253
  var name_4 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
56133
- ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here_Colon, name_4); });
56254
+ ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_4); });
56134
56255
  error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_4);
56135
56256
  lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
56136
56257
  }
@@ -57161,6 +57282,11 @@ var ts;
57161
57282
  return simplified !== type ? simplified : getConstraintOfType(type);
57162
57283
  }
57163
57284
  function getConstraintFromIndexedAccess(type) {
57285
+ if (isMappedTypeGenericIndexedAccess(type)) {
57286
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57287
+ // we substitute an instantiation of E where P is replaced with X.
57288
+ return substituteIndexedMappedType(type.objectType, type.indexType);
57289
+ }
57164
57290
  var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
57165
57291
  if (indexConstraint && indexConstraint !== type.indexType) {
57166
57292
  var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags);
@@ -57365,6 +57491,11 @@ var ts;
57365
57491
  return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
57366
57492
  }
57367
57493
  if (t.flags & 8388608 /* IndexedAccess */) {
57494
+ if (isMappedTypeGenericIndexedAccess(t)) {
57495
+ // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
57496
+ // we substitute an instantiation of E where P is replaced with X.
57497
+ return getBaseConstraint(substituteIndexedMappedType(t.objectType, t.indexType));
57498
+ }
57368
57499
  var baseObjectType = getBaseConstraint(t.objectType);
57369
57500
  var baseIndexType = getBaseConstraint(t.indexType);
57370
57501
  var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
@@ -57449,13 +57580,7 @@ var ts;
57449
57580
  * type itself.
57450
57581
  */
57451
57582
  function getApparentType(type) {
57452
- // We obtain the base constraint for all instantiable types, except indexed access types of the form
57453
- // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57454
- // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57455
- // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57456
- var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57457
- isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57458
- getBaseConstraintOfType(type) || unknownType;
57583
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
57459
57584
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57460
57585
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57461
57586
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -57793,7 +57918,7 @@ var ts;
57793
57918
  // signature applies to types assignable to 'number' and numeric string literal types.
57794
57919
  return isTypeAssignableTo(source, target) ||
57795
57920
  target === stringType && isTypeAssignableTo(source, numberType) ||
57796
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value);
57921
+ target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
57797
57922
  }
57798
57923
  function getIndexInfosOfStructuredType(type) {
57799
57924
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60359,7 +60484,7 @@ var ts;
60359
60484
  getFlowTypeOfReference(accessExpression, propType) :
60360
60485
  propType;
60361
60486
  }
60362
- if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
60487
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
60363
60488
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
60364
60489
  var indexNode = getIndexNodeForAccessExpression(accessNode);
60365
60490
  if (isTupleType(objectType)) {
@@ -60644,7 +60769,7 @@ var ts;
60644
60769
  return everyType(indexType, function (t) {
60645
60770
  if (t.flags & 384 /* StringOrNumberLiteral */) {
60646
60771
  var propName = getPropertyNameFromType(t);
60647
- if (isNumericLiteralName(propName)) {
60772
+ if (ts.isNumericLiteralName(propName)) {
60648
60773
  var index = +propName;
60649
60774
  return index >= 0 && index < limit;
60650
60775
  }
@@ -64119,6 +64244,17 @@ var ts;
64119
64244
  resetErrorInfo(saveErrorInfo);
64120
64245
  return result;
64121
64246
  }
64247
+ if (isMappedTypeGenericIndexedAccess(source)) {
64248
+ // For an indexed access type { [P in K]: E}[X], above we have already explored an instantiation of E with X
64249
+ // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
64250
+ var indexConstraint = getConstraintOfType(source.indexType);
64251
+ if (indexConstraint) {
64252
+ if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
64253
+ resetErrorInfo(saveErrorInfo);
64254
+ return result;
64255
+ }
64256
+ }
64257
+ }
64122
64258
  }
64123
64259
  }
64124
64260
  else if (source.flags & 4194304 /* Index */) {
@@ -64186,7 +64322,7 @@ var ts;
64186
64322
  else {
64187
64323
  // conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way
64188
64324
  // more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
64189
- var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
64325
+ var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
64190
64326
  if (distributiveConstraint) {
64191
64327
  if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
64192
64328
  resetErrorInfo(saveErrorInfo);
@@ -64583,7 +64719,7 @@ var ts;
64583
64719
  var propName = symbolToString(unmatchedProperty);
64584
64720
  reportError.apply(void 0, __spreadArray([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target), false));
64585
64721
  if (ts.length(unmatchedProperty.declarations)) {
64586
- associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here_Colon, propName));
64722
+ associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
64587
64723
  }
64588
64724
  if (shouldSkipElaboration && errorInfo) {
64589
64725
  overrideNextErrorInfo++;
@@ -64732,7 +64868,7 @@ var ts;
64732
64868
  for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
64733
64869
  var targetProp = _c[_b];
64734
64870
  var name = targetProp.escapedName;
64735
- if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
64871
+ if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
64736
64872
  var sourceProp = getPropertyOfType(source, name);
64737
64873
  if (sourceProp && sourceProp !== targetProp) {
64738
64874
  var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
@@ -64805,7 +64941,8 @@ var ts;
64805
64941
  var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
64806
64942
  var sourceObjectFlags = ts.getObjectFlags(source);
64807
64943
  var targetObjectFlags = ts.getObjectFlags(target);
64808
- if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol) {
64944
+ if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol ||
64945
+ sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) {
64809
64946
  // We have instantiations of the same anonymous type (which typically will be the type of a
64810
64947
  // method). Simply do a pairwise comparison of the signatures in the two signature lists instead
64811
64948
  // of the much more expensive N * M comparison matrix we explore below. We erase type parameters
@@ -65840,9 +65977,12 @@ var ts;
65840
65977
  * with no call or construct signatures.
65841
65978
  */
65842
65979
  function isObjectTypeWithInferableIndex(type) {
65843
- return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) :
65844
- !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 &&
65845
- !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
65980
+ return type.flags & 2097152 /* Intersection */
65981
+ ? ts.every(type.types, isObjectTypeWithInferableIndex)
65982
+ : !!(type.symbol
65983
+ && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
65984
+ && !(type.symbol.flags & 32 /* Class */)
65985
+ && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
65846
65986
  }
65847
65987
  function createSymbolWithType(source, type) {
65848
65988
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
@@ -70812,7 +70952,7 @@ var ts;
70812
70952
  }
70813
70953
  if (isTupleType(t)) {
70814
70954
  var restType = getRestTypeOfTupleType(t);
70815
- if (restType && isNumericLiteralName(name) && +name >= 0) {
70955
+ if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
70816
70956
  return restType;
70817
70957
  }
70818
70958
  }
@@ -71453,10 +71593,10 @@ var ts;
71453
71593
  case 161 /* ComputedPropertyName */:
71454
71594
  return isNumericComputedName(name);
71455
71595
  case 79 /* Identifier */:
71456
- return isNumericLiteralName(name.escapedText);
71596
+ return ts.isNumericLiteralName(name.escapedText);
71457
71597
  case 8 /* NumericLiteral */:
71458
71598
  case 10 /* StringLiteral */:
71459
- return isNumericLiteralName(name.text);
71599
+ return ts.isNumericLiteralName(name.text);
71460
71600
  default:
71461
71601
  return false;
71462
71602
  }
@@ -71466,30 +71606,6 @@ var ts;
71466
71606
  // but this behavior is consistent with checkIndexedAccess
71467
71607
  return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
71468
71608
  }
71469
- function isNumericLiteralName(name) {
71470
- // The intent of numeric names is that
71471
- // - they are names with text in a numeric form, and that
71472
- // - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
71473
- // acquired by applying the abstract 'ToNumber' operation on the name's text.
71474
- //
71475
- // The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
71476
- // In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
71477
- //
71478
- // Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
71479
- // according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
71480
- // Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
71481
- // because their 'ToString' representation is not equal to their original text.
71482
- // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
71483
- //
71484
- // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
71485
- // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
71486
- // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
71487
- //
71488
- // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
71489
- // This is desired behavior, because when indexing with them as numeric entities, you are indexing
71490
- // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
71491
- return (+name).toString() === name;
71492
- }
71493
71609
  function checkComputedPropertyName(node) {
71494
71610
  var links = getNodeLinks(node.expression);
71495
71611
  if (!links.resolvedType) {
@@ -71525,7 +71641,7 @@ var ts;
71525
71641
  function isSymbolWithNumericName(symbol) {
71526
71642
  var _a;
71527
71643
  var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
71528
- return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
71644
+ return ts.isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
71529
71645
  }
71530
71646
  function isSymbolWithSymbolName(symbol) {
71531
71647
  var _a;
@@ -72748,6 +72864,9 @@ var ts;
72748
72864
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
72749
72865
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
72750
72866
  }
72867
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
72868
+ addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
72869
+ }
72751
72870
  }
72752
72871
  else {
72753
72872
  if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
@@ -72854,7 +72973,7 @@ var ts;
72854
72973
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
72855
72974
  }
72856
72975
  if (diagnosticMessage) {
72857
- ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, declarationName));
72976
+ ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
72858
72977
  }
72859
72978
  }
72860
72979
  function isInPropertyInitializerOrClassStaticBlock(node) {
@@ -72948,7 +73067,7 @@ var ts;
72948
73067
  var suggestedName = ts.symbolName(suggestion);
72949
73068
  var message = isUncheckedJS ? ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2 : ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2;
72950
73069
  errorInfo = ts.chainDiagnosticMessages(errorInfo, message, missingProperty, container, suggestedName);
72951
- relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here_Colon, suggestedName);
73070
+ relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
72952
73071
  }
72953
73072
  else {
72954
73073
  var diagnostic = containerSeemsToBeEmptyDomElement(containingType)
@@ -73732,7 +73851,7 @@ var ts;
73732
73851
  var diag = ts.createDiagnosticForNode(node.tagName, ts.Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, ts.entityNameToString(node.tagName), absoluteMinArgCount, ts.entityNameToString(factory), maxParamCount);
73733
73852
  var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
73734
73853
  if (tagNameDeclaration) {
73735
- ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here_Colon, ts.entityNameToString(node.tagName)));
73854
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
73736
73855
  }
73737
73856
  if (errorOutputContainer && errorOutputContainer.skipLogging) {
73738
73857
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -80475,7 +80594,7 @@ var ts;
80475
80594
  var declName = ts.declarationNameToString(nextDeclarationName);
80476
80595
  var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
80477
80596
  if (firstDeclaration) {
80478
- ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here_Colon, declName));
80597
+ ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
80479
80598
  }
80480
80599
  }
80481
80600
  function areDeclarationFlagsIdentical(left, right) {
@@ -82463,7 +82582,7 @@ var ts;
82463
82582
  }
82464
82583
  else {
82465
82584
  var text = ts.getTextOfPropertyName(member.name);
82466
- if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
82585
+ if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
82467
82586
  error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
82468
82587
  }
82469
82588
  }
@@ -83257,9 +83376,9 @@ var ts;
83257
83376
  }
83258
83377
  }
83259
83378
  // Checks for export * conflicts
83260
- var exports_2 = getExportsOfModule(moduleSymbol);
83261
- if (exports_2) {
83262
- exports_2.forEach(function (_a, id) {
83379
+ var exports_3 = getExportsOfModule(moduleSymbol);
83380
+ if (exports_3) {
83381
+ exports_3.forEach(function (_a, id) {
83263
83382
  var declarations = _a.declarations, flags = _a.flags;
83264
83383
  if (id === "__export") {
83265
83384
  return;
@@ -92815,6 +92934,11 @@ var ts;
92815
92934
  ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
92816
92935
  ts.setCommentRange(statement, property);
92817
92936
  ts.setOriginalNode(statement, property);
92937
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
92938
+ // `statement` and `expression` have a copy of the synthesized comments.
92939
+ // Drop the comments from expression to avoid printing them twice.
92940
+ ts.setSyntheticLeadingComments(expression, undefined);
92941
+ ts.setSyntheticTrailingComments(expression, undefined);
92818
92942
  statements.push(statement);
92819
92943
  }
92820
92944
  }
@@ -113343,8 +113467,8 @@ var ts;
113343
113467
  var gutterSeparator = " ";
113344
113468
  var resetEscapeSequence = "\u001b[0m";
113345
113469
  var ellipsis = "...";
113346
- var bullet = "● ";
113347
113470
  var halfIndent = " ";
113471
+ var indent = " ";
113348
113472
  function getCategoryFormat(category) {
113349
113473
  switch (category) {
113350
113474
  case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
@@ -113358,22 +113482,14 @@ var ts;
113358
113482
  return formatStyle + text + resetEscapeSequence;
113359
113483
  }
113360
113484
  ts.formatColorAndReset = formatColorAndReset;
113361
- function formatCodeSpan(file, start, length, indent, underlineColor, host) {
113485
+ function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
113362
113486
  var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
113363
113487
  var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
113364
113488
  var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
113365
- var gutterWidth = 1;
113366
113489
  var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
113367
- // Dedent all of the code lines consistently
113368
- var whitespaceToTrim = Number.MAX_VALUE;
113369
- for (var i = firstLine; i <= lastLine; i++) {
113370
- if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
113371
- i = lastLine - 1;
113372
- }
113373
- var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
113374
- var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
113375
- var lineContent = file.text.slice(lineStart, lineEnd);
113376
- whitespaceToTrim = Math.min(whitespaceToTrim, ts.startWhitespaceCount(lineContent));
113490
+ var gutterWidth = (lastLine + 1 + "").length;
113491
+ if (hasMoreThanFiveLines) {
113492
+ gutterWidth = Math.max(ellipsis.length, gutterWidth);
113377
113493
  }
113378
113494
  var context = "";
113379
113495
  for (var i = firstLine; i <= lastLine; i++) {
@@ -113388,31 +113504,26 @@ var ts;
113388
113504
  var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
113389
113505
  var lineContent = file.text.slice(lineStart, lineEnd);
113390
113506
  lineContent = ts.trimStringEnd(lineContent); // trim from end
113391
- lineContent = lineContent.slice(whitespaceToTrim); // remove preceding whitespaces
113392
113507
  lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
113393
- // TODO: the extra characters for the grey bar has confusing issues
113394
- // const gutterLine = ForegroundColorEscapeSequences.Grey + "|" + resetEscapeSequence;
113395
113508
  // Output the gutter and the actual contents of the line.
113396
- var gutterLine = "|";
113397
- context += indent + ts.padLeft(gutterLine, gutterWidth) + gutterSeparator;
113509
+ context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
113398
113510
  context += lineContent + host.getNewLine();
113399
- // Output the gutter and the error span for the line using underlines.
113400
- context += indent + ts.padLeft("", gutterWidth) + gutterSeparator;
113401
- context += underlineColor;
113511
+ // Output the gutter and the error span for the line using tildes.
113512
+ context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
113513
+ context += squiggleColor;
113402
113514
  if (i === firstLine) {
113403
113515
  // If we're on the last line, then limit it to the last character of the last line.
113404
- // Otherwise, we'll just underline the rest of the line, giving 'slice' no end position.
113516
+ // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
113405
113517
  var lastCharForLine = i === lastLine ? lastLineChar : undefined;
113406
- context += lineContent.slice(0, firstLineChar - whitespaceToTrim).replace(/\S/g, " ");
113407
- var amendedLastChar = lastCharForLine ? lastCharForLine - whitespaceToTrim : undefined;
113408
- context += lineContent.slice(firstLineChar - whitespaceToTrim, amendedLastChar).replace(/./g, "▔");
113518
+ context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
113519
+ context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
113409
113520
  }
113410
113521
  else if (i === lastLine) {
113411
- context += lineContent.slice(0, lastLineChar).replace(/./g, "▔");
113522
+ context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
113412
113523
  }
113413
113524
  else {
113414
- // Underline the entire line.
113415
- context += lineContent.replace(/./g, "▔");
113525
+ // Squiggle the entire line.
113526
+ context += lineContent.replace(/./g, "~");
113416
113527
  }
113417
113528
  context += resetEscapeSequence;
113418
113529
  }
@@ -113433,54 +113544,41 @@ var ts;
113433
113544
  }
113434
113545
  ts.formatLocation = formatLocation;
113435
113546
  function formatDiagnosticsWithColorAndContext(diagnostics, host) {
113436
- var _a, _b;
113437
- var terminalWidth = (_b = (_a = ts.sys.getWidthOfTerminal) === null || _a === void 0 ? void 0 : _a.call(ts.sys)) !== null && _b !== void 0 ? _b : 0;
113438
- var indent = terminalWidth < 60 ? "" : halfIndent;
113439
113547
  var output = "";
113440
113548
  for (var _i = 0, diagnostics_4 = diagnostics; _i < diagnostics_4.length; _i++) {
113441
113549
  var diagnostic = diagnostics_4[_i];
113442
- var diagnosticCode = "TS" + diagnostic.code;
113443
113550
  if (diagnostic.file) {
113444
113551
  var file = diagnostic.file, start = diagnostic.start;
113445
- var location = formatLocation(file, start, host); // TODO: GH#18217
113446
- // Get the location string display length without color & escape sequences.
113447
- var locationLength = location.replace(/\u001b[[0-9]+m/g, "").length;
113448
- var codeLength = diagnosticCode.length;
113449
- output += bullet + location;
113450
- // Separate the error code from the location by a space on thinner terminals
113451
- // and those of unknown length, or right-align it on wider terminals.
113452
- var defaultPad = codeLength + 1;
113453
- var padWidth = terminalWidth < 60 ? defaultPad : terminalWidth - (bullet.length + locationLength + codeLength);
113454
- if (padWidth < diagnosticCode.length)
113455
- padWidth = defaultPad;
113456
- output += ts.padLeft(diagnosticCode, padWidth);
113457
- output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, indent, getCategoryFormat(diagnostic.category), host); // TODO: GH#18217
113552
+ output += formatLocation(file, start, host); // TODO: GH#18217
113553
+ output += " - ";
113554
+ }
113555
+ output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
113556
+ output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
113557
+ output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
113558
+ if (diagnostic.file) {
113458
113559
  output += host.getNewLine();
113560
+ output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host); // TODO: GH#18217
113459
113561
  }
113460
- var diagnosticText = flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine(), 0, /*pretty*/ true);
113461
- diagnosticText = ts.map(diagnosticText.split(host.getNewLine()), function (text) { return indent + text; }).join(host.getNewLine());
113462
- output += diagnosticText;
113463
- output += host.getNewLine();
113464
113562
  if (diagnostic.relatedInformation) {
113465
113563
  output += host.getNewLine();
113466
- for (var _c = 0, _d = diagnostic.relatedInformation; _c < _d.length; _c++) {
113467
- var _e = _d[_c], file = _e.file, start = _e.start, length_9 = _e.length, messageText = _e.messageText;
113468
- output += ts.trimStringStart(flattenDiagnosticMessageText(messageText, host.getNewLine(), 0, /*pretty*/ true));
113469
- // output += host.getNewLine();
113564
+ for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
113565
+ var _c = _b[_a], file = _c.file, start = _c.start, length_9 = _c.length, messageText = _c.messageText;
113470
113566
  if (file) {
113471
- output += " " + formatLocation(file, start, host); // TODO: GH#18217
113472
113567
  output += host.getNewLine();
113473
- output += formatCodeSpan(file, start, length_9, indent + " ", ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
113568
+ output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217
113569
+ output += formatCodeSpan(file, start, length_9, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217
113474
113570
  }
113571
+ output += host.getNewLine();
113572
+ output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
113475
113573
  }
113476
113574
  }
113575
+ output += host.getNewLine();
113477
113576
  }
113478
113577
  return output;
113479
113578
  }
113480
113579
  ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
113481
- function flattenDiagnosticMessageText(diag, newLine, indent, pretty) {
113580
+ function flattenDiagnosticMessageText(diag, newLine, indent) {
113482
113581
  if (indent === void 0) { indent = 0; }
113483
- if (pretty === void 0) { pretty = false; }
113484
113582
  if (ts.isString(diag)) {
113485
113583
  return diag;
113486
113584
  }
@@ -113490,16 +113588,9 @@ var ts;
113490
113588
  var result = "";
113491
113589
  if (indent) {
113492
113590
  result += newLine;
113493
- // If using pretty formatting, the second line shouldn't be indented past the first,
113494
- // instead separating the two with an extra empty line.
113495
- var indentsToReplaceWithNewLines = pretty ? 1 : 0;
113496
- if (indent > indentsToReplaceWithNewLines) {
113497
- for (var i = indentsToReplaceWithNewLines; i < indent; i++) {
113498
- result += " ";
113499
- }
113591
+ for (var i = 0; i < indent; i++) {
113592
+ result += " ";
113500
113593
  }
113501
- else
113502
- result += newLine;
113503
113594
  }
113504
113595
  result += diag.messageText;
113505
113596
  indent++;
@@ -119188,28 +119279,37 @@ var ts;
119188
119279
  useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
119189
119280
  };
119190
119281
  }
119191
- function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119192
- var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119282
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119283
+ // Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
119284
+ // while `importingSourceFileName` its *new* name. We need a source file just to get its
119285
+ // `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
119286
+ function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
119287
+ var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
119193
119288
  if (res === oldImportSpecifier)
119194
119289
  return undefined;
119195
119290
  return res;
119196
119291
  }
119197
119292
  moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
119198
- // Note: importingSourceFile is just for usesJsExtensionOnImports
119293
+ // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
119294
+ // Because when this is called by the declaration emitter, `importingSourceFile` is the implementation
119295
+ // file, but `importingSourceFileName` and `toFileName` refer to declaration files (the former to the
119296
+ // one currently being produced; the latter to the one being imported). We need an implementation file
119297
+ // just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
119298
+ // specifiers.
119199
119299
  function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
119200
- return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119300
+ return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
119201
119301
  }
119202
119302
  moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
119203
- function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
119204
- var info = getInfo(importingSourceFileName, host);
119205
- var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host, preferences);
119206
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); });
119303
+ function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
119304
+ var info = getInfo(importingSourceFile.path, host);
119305
+ var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
119306
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
119207
119307
  }
119208
119308
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
119209
- function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119309
+ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
119210
119310
  var info = getInfo(importingSourceFileName, host);
119211
119311
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
119212
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
119312
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
119213
119313
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
119214
119314
  }
119215
119315
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
@@ -119276,7 +119376,7 @@ var ts;
119276
119376
  var relativeSpecifiers;
119277
119377
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
119278
119378
  var modulePath = modulePaths_1[_i];
119279
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
119379
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
119280
119380
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
119281
119381
  if (specifier && modulePath.isRedirect) {
119282
119382
  // If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
@@ -119668,7 +119768,7 @@ var ts;
119668
119768
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
119669
119769
  : ts.removeFileExtension(relativePath);
119670
119770
  }
119671
- function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
119771
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
119672
119772
  var path = _a.path, isRedirect = _a.isRedirect;
119673
119773
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
119674
119774
  if (!host.fileExists || !host.readFile) {
@@ -119731,11 +119831,19 @@ var ts;
119731
119831
  var moduleFileToTry = path;
119732
119832
  if (host.fileExists(packageJsonPath)) {
119733
119833
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119734
- // TODO: Inject `require` or `import` condition based on the intended import mode
119735
119834
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119736
- var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119835
+ // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
119836
+ // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
119837
+ // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
119838
+ // with, so for now we just stick with the mode of the file.
119839
+ var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
119840
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
119841
+ ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
119842
+ : undefined;
119737
119843
  if (fromExports) {
119738
- var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119844
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
119845
+ ? fromExports
119846
+ : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119739
119847
  return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119740
119848
  }
119741
119849
  if (packageJsonContent.exports) {
@@ -119841,8 +119949,8 @@ var ts;
119841
119949
  }
119842
119950
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
119843
119951
  return ts.firstDefined(rootDirs, function (rootDir) {
119844
- var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); // TODO: GH#18217
119845
- return isPathRelativeToParent(relativePath) ? undefined : relativePath;
119952
+ var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
119953
+ return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
119846
119954
  });
119847
119955
  }
119848
119956
  function removeExtensionAndIndexPostFix(fileName, ending, options) {
@@ -119961,7 +120069,7 @@ var ts;
119961
120069
  }
119962
120070
  ts.getLocaleTimeString = getLocaleTimeString;
119963
120071
  /**
119964
- * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic
120072
+ * Create a function that reports watch status by writing to the system and handles the formatting of the diagnostic
119965
120073
  */
119966
120074
  function createWatchStatusReporter(system, pretty) {
119967
120075
  return pretty ?
@@ -120022,7 +120130,7 @@ var ts;
120022
120130
  ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
120023
120131
  }
120024
120132
  ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
120025
- function getErrorSummaryText(errorCount, filesInError, newLine) {
120133
+ function getErrorSummaryText(errorCount, filesInError, newLine, host) {
120026
120134
  if (errorCount === 0)
120027
120135
  return "";
120028
120136
  var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
@@ -120037,10 +120145,10 @@ var ts;
120037
120145
  distinctFileNamesWithLines.length === 1 ?
120038
120146
  ts.Diagnostics.Found_0_errors_in_1_file :
120039
120147
  ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
120040
- return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles) : "");
120148
+ return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
120041
120149
  }
120042
120150
  ts.getErrorSummaryText = getErrorSummaryText;
120043
- function createTabularErrorsDisplay(filesInError) {
120151
+ function createTabularErrorsDisplay(filesInError, host) {
120044
120152
  var distinctFiles = filesInError.filter(function (value, index, self) { return index === self.findIndex(function (file) { return (file === null || file === void 0 ? void 0 : file.fileName) === (value === null || value === void 0 ? void 0 : value.fileName); }); });
120045
120153
  if (distinctFiles.length === 0)
120046
120154
  return "";
@@ -120059,7 +120167,8 @@ var ts;
120059
120167
  var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
120060
120168
  " ".repeat(leftPaddingGoal - errorCountDigitsLength)
120061
120169
  : "";
120062
- tabularData += "" + leftPadding + errorCount + " " + file.fileName + ":" + file.line + "\n";
120170
+ var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
120171
+ tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
120063
120172
  });
120064
120173
  return tabularData;
120065
120174
  }
@@ -120477,7 +120586,7 @@ var ts;
120477
120586
  var system = input.system || ts.sys;
120478
120587
  var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
120479
120588
  var builderProgram = ts.createIncrementalProgram(input);
120480
- var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine)); } : undefined);
120589
+ var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine, host)); } : undefined);
120481
120590
  if (input.afterProgramEmitAndDiagnostics)
120482
120591
  input.afterProgramEmitAndDiagnostics(builderProgram);
120483
120592
  return exitStatus;
@@ -126053,7 +126162,7 @@ var ts;
126053
126162
  if (!ts.stringContains(importedFileName, "node_modules")) {
126054
126163
  return undefined;
126055
126164
  }
126056
- var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, preferences);
126165
+ var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile, importedFileName, moduleSpecifierResolutionHost, preferences);
126057
126166
  if (!specifier) {
126058
126167
  return undefined;
126059
126168
  }
@@ -135699,7 +135808,7 @@ var ts;
135699
135808
  : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
135700
135809
  // Need an update if the imported file moved, or the importing file moved and was using a relative path.
135701
135810
  return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
135702
- ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
135811
+ ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
135703
135812
  : undefined;
135704
135813
  });
135705
135814
  };
@@ -137344,6 +137453,9 @@ var ts;
137344
137453
  // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
137345
137454
  // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
137346
137455
  function areSameModule(a, b) {
137456
+ if (!a.body || !b.body) {
137457
+ return a.body === b.body;
137458
+ }
137347
137459
  return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
137348
137460
  }
137349
137461
  /** Merge source into target. Source should be thrown away after this is called. */
@@ -150462,7 +150574,8 @@ var ts;
150462
150574
  return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, indentation: undefined, parentDeclaration: parent.initializer };
150463
150575
  }
150464
150576
  if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
150465
- var attributes = getUnmatchedAttributes(checker, token.parent);
150577
+ var target = ts.getEmitScriptTarget(program.getCompilerOptions());
150578
+ var attributes = getUnmatchedAttributes(checker, target, token.parent);
150466
150579
  if (!ts.length(attributes))
150467
150580
  return undefined;
150468
150581
  return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
@@ -150697,8 +150810,12 @@ var ts;
150697
150810
  var jsxAttributesNode = info.parentDeclaration.attributes;
150698
150811
  var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
150699
150812
  var attrs = ts.map(info.attributes, function (attr) {
150700
- var value = attr.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(attr.valueDeclaration)) : createUndefined();
150701
- return ts.factory.createJsxAttribute(ts.factory.createIdentifier(attr.name), ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
150813
+ var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
150814
+ var name = ts.factory.createIdentifier(attr.name);
150815
+ var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
150816
+ // formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
150817
+ ts.setParent(name, jsxAttribute);
150818
+ return jsxAttribute;
150702
150819
  });
150703
150820
  var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
150704
150821
  var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
@@ -150707,10 +150824,11 @@ var ts;
150707
150824
  function addObjectLiteralProperties(changes, context, info) {
150708
150825
  var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
150709
150826
  var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
150827
+ var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
150710
150828
  var checker = context.program.getTypeChecker();
150711
150829
  var props = ts.map(info.properties, function (prop) {
150712
- var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined();
150713
- return ts.factory.createPropertyAssignment(prop.name, initializer);
150830
+ var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
150831
+ return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
150714
150832
  });
150715
150833
  var options = {
150716
150834
  leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
@@ -150797,7 +150915,7 @@ var ts;
150797
150915
  return (type.flags & 524288 /* Object */) &&
150798
150916
  ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode)));
150799
150917
  }
150800
- function getUnmatchedAttributes(checker, source) {
150918
+ function getUnmatchedAttributes(checker, target, source) {
150801
150919
  var attrsType = checker.getContextualType(source.attributes);
150802
150920
  if (attrsType === undefined)
150803
150921
  return ts.emptyArray;
@@ -150819,7 +150937,7 @@ var ts;
150819
150937
  }
150820
150938
  }
150821
150939
  return ts.filter(targetProps, function (targetProp) {
150822
- return !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
150940
+ return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
150823
150941
  });
150824
150942
  }
150825
150943
  })(codefix = ts.codefix || (ts.codefix = {}));
@@ -154552,7 +154670,7 @@ var ts;
154552
154670
  defaultToNamedAction.kind,
154553
154671
  namedToDefaultAction.kind
154554
154672
  ],
154555
- getAvailableActions: function (context) {
154673
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndDefaultExports(context) {
154556
154674
  var info = getInfo(context, context.triggerReason === "invoked");
154557
154675
  if (!info)
154558
154676
  return ts.emptyArray;
@@ -154570,7 +154688,7 @@ var ts;
154570
154688
  }
154571
154689
  return ts.emptyArray;
154572
154690
  },
154573
- getEditsForAction: function (context, actionName) {
154691
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndDefaultExports(context, actionName) {
154574
154692
  ts.Debug.assert(actionName === defaultToNamedAction.name || actionName === namedToDefaultAction.name, "Unexpected action name");
154575
154693
  var info = getInfo(context);
154576
154694
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -154798,7 +154916,7 @@ var ts;
154798
154916
  namespaceToNamedAction.kind,
154799
154917
  namedToNamespaceAction.kind
154800
154918
  ],
154801
- getAvailableActions: function (context) {
154919
+ getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
154802
154920
  var info = getImportToConvert(context, context.triggerReason === "invoked");
154803
154921
  if (!info)
154804
154922
  return ts.emptyArray;
@@ -154817,7 +154935,7 @@ var ts;
154817
154935
  }
154818
154936
  return ts.emptyArray;
154819
154937
  },
154820
- getEditsForAction: function (context, actionName) {
154938
+ getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
154821
154939
  ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
154822
154940
  var info = getImportToConvert(context);
154823
154941
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -154983,10 +155101,10 @@ var ts;
154983
155101
  };
154984
155102
  refactor.registerRefactor(refactorName, {
154985
155103
  kinds: [toOptionalChainAction.kind],
154986
- getAvailableActions: getAvailableActions,
154987
- getEditsForAction: getEditsForAction
155104
+ getEditsForAction: getRefactorEditsToConvertToOptionalChain,
155105
+ getAvailableActions: getRefactorActionsToConvertToOptionalChain,
154988
155106
  });
154989
- function getAvailableActions(context) {
155107
+ function getRefactorActionsToConvertToOptionalChain(context) {
154990
155108
  var info = getInfo(context, context.triggerReason === "invoked");
154991
155109
  if (!info)
154992
155110
  return ts.emptyArray;
@@ -155006,7 +155124,7 @@ var ts;
155006
155124
  }
155007
155125
  return ts.emptyArray;
155008
155126
  }
155009
- function getEditsForAction(context, actionName) {
155127
+ function getRefactorEditsToConvertToOptionalChain(context, actionName) {
155010
155128
  var info = getInfo(context);
155011
155129
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155012
155130
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
@@ -155249,10 +155367,10 @@ var ts;
155249
155367
  };
155250
155368
  refactor.registerRefactor(refactorName, {
155251
155369
  kinds: [functionOverloadAction.kind],
155252
- getEditsForAction: getEditsForAction,
155253
- getAvailableActions: getAvailableActions
155370
+ getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
155371
+ getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
155254
155372
  });
155255
- function getAvailableActions(context) {
155373
+ function getRefactorActionsToConvertOverloadsToOneSignature(context) {
155256
155374
  var file = context.file, startPosition = context.startPosition, program = context.program;
155257
155375
  var info = getConvertableOverloadListAtPosition(file, startPosition, program);
155258
155376
  if (!info)
@@ -155263,7 +155381,7 @@ var ts;
155263
155381
  actions: [functionOverloadAction]
155264
155382
  }];
155265
155383
  }
155266
- function getEditsForAction(context) {
155384
+ function getRefactorEditsToConvertOverloadsToOneSignature(context) {
155267
155385
  var file = context.file, startPosition = context.startPosition, program = context.program;
155268
155386
  var signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
155269
155387
  if (!signatureDecls)
@@ -155419,14 +155537,14 @@ var ts;
155419
155537
  extractConstantAction.kind,
155420
155538
  extractFunctionAction.kind
155421
155539
  ],
155422
- getAvailableActions: getAvailableActions,
155423
- getEditsForAction: getEditsForAction
155540
+ getEditsForAction: getRefactorEditsToExtractSymbol,
155541
+ getAvailableActions: getRefactorActionsToExtractSymbol,
155424
155542
  });
155425
155543
  /**
155426
155544
  * Compute the associated code actions
155427
155545
  * Exported for tests.
155428
155546
  */
155429
- function getAvailableActions(context) {
155547
+ function getRefactorActionsToExtractSymbol(context) {
155430
155548
  var requestedRefactor = context.kind;
155431
155549
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context), context.triggerReason === "invoked");
155432
155550
  var targetRange = rangeToExtract.targetRange;
@@ -155555,9 +155673,9 @@ var ts;
155555
155673
  return error;
155556
155674
  }
155557
155675
  }
155558
- extractSymbol.getAvailableActions = getAvailableActions;
155676
+ extractSymbol.getRefactorActionsToExtractSymbol = getRefactorActionsToExtractSymbol;
155559
155677
  /* Exported for tests */
155560
- function getEditsForAction(context, actionName) {
155678
+ function getRefactorEditsToExtractSymbol(context, actionName) {
155561
155679
  var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context));
155562
155680
  var targetRange = rangeToExtract.targetRange; // TODO:GH#18217
155563
155681
  var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
@@ -155574,7 +155692,7 @@ var ts;
155574
155692
  }
155575
155693
  ts.Debug.fail("Unrecognized action name");
155576
155694
  }
155577
- extractSymbol.getEditsForAction = getEditsForAction;
155695
+ extractSymbol.getRefactorEditsToExtractSymbol = getRefactorEditsToExtractSymbol;
155578
155696
  // Move these into diagnostic messages if they become user-facing
155579
155697
  var Messages;
155580
155698
  (function (Messages) {
@@ -157125,7 +157243,7 @@ var ts;
157125
157243
  extractToInterfaceAction.kind,
157126
157244
  extractToTypeDefAction.kind
157127
157245
  ],
157128
- getAvailableActions: function (context) {
157246
+ getAvailableActions: function getRefactorActionsToExtractType(context) {
157129
157247
  var info = getRangeToExtract(context, context.triggerReason === "invoked");
157130
157248
  if (!info)
157131
157249
  return ts.emptyArray;
@@ -157150,7 +157268,7 @@ var ts;
157150
157268
  }
157151
157269
  return ts.emptyArray;
157152
157270
  },
157153
- getEditsForAction: function (context, actionName) {
157271
+ getEditsForAction: function getRefactorEditsToExtractType(context, actionName) {
157154
157272
  var file = context.file;
157155
157273
  var info = getRangeToExtract(context);
157156
157274
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected to find a range to extract");
@@ -157318,7 +157436,7 @@ var ts;
157318
157436
  };
157319
157437
  refactor.registerRefactor(actionName, {
157320
157438
  kinds: [generateGetSetAction.kind],
157321
- getEditsForAction: function (context, actionName) {
157439
+ getEditsForAction: function getRefactorActionsToGenerateGetAndSetAccessors(context, actionName) {
157322
157440
  if (!context.endPosition)
157323
157441
  return undefined;
157324
157442
  var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition);
@@ -157397,7 +157515,7 @@ var ts;
157397
157515
  };
157398
157516
  refactor.registerRefactor(refactorName, {
157399
157517
  kinds: [moveToNewFileAction.kind],
157400
- getAvailableActions: function (context) {
157518
+ getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
157401
157519
  var statements = getStatementsToMove(context);
157402
157520
  if (context.preferences.allowTextChangesInNewFiles && statements) {
157403
157521
  return [{ name: refactorName, description: description, actions: [moveToNewFileAction] }];
@@ -157408,7 +157526,7 @@ var ts;
157408
157526
  }
157409
157527
  return ts.emptyArray;
157410
157528
  },
157411
- getEditsForAction: function (context, actionName) {
157529
+ getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName) {
157412
157530
  ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
157413
157531
  var statements = ts.Debug.checkDefined(getStatementsToMove(context));
157414
157532
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
@@ -158139,10 +158257,10 @@ var ts;
158139
158257
  };
158140
158258
  refactor.registerRefactor(refactorName, {
158141
158259
  kinds: [removeBracesAction.kind],
158142
- getEditsForAction: getEditsForAction,
158143
- getAvailableActions: getAvailableActions
158260
+ getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
158261
+ getAvailableActions: getRefactorActionsToRemoveFunctionBraces
158144
158262
  });
158145
- function getAvailableActions(context) {
158263
+ function getRefactorActionsToRemoveFunctionBraces(context) {
158146
158264
  var file = context.file, startPosition = context.startPosition, triggerReason = context.triggerReason;
158147
158265
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition, triggerReason === "invoked");
158148
158266
  if (!info)
@@ -158168,7 +158286,7 @@ var ts;
158168
158286
  }
158169
158287
  return ts.emptyArray;
158170
158288
  }
158171
- function getEditsForAction(context, actionName) {
158289
+ function getRefactorEditsToRemoveFunctionBraces(context, actionName) {
158172
158290
  var file = context.file, startPosition = context.startPosition;
158173
158291
  var info = getConvertibleArrowFunctionAtPosition(file, startPosition);
158174
158292
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
@@ -158242,10 +158360,10 @@ var ts;
158242
158360
  };
158243
158361
  refactor.registerRefactor(refactorName, {
158244
158362
  kinds: [toDestructuredAction.kind],
158245
- getEditsForAction: getEditsForAction,
158246
- getAvailableActions: getAvailableActions
158363
+ getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
158364
+ getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
158247
158365
  });
158248
- function getAvailableActions(context) {
158366
+ function getRefactorActionsToConvertParametersToDestructuredObject(context) {
158249
158367
  var file = context.file, startPosition = context.startPosition;
158250
158368
  var isJSFile = ts.isSourceFileJS(file);
158251
158369
  if (isJSFile)
@@ -158259,7 +158377,7 @@ var ts;
158259
158377
  actions: [toDestructuredAction]
158260
158378
  }];
158261
158379
  }
158262
- function getEditsForAction(context, actionName) {
158380
+ function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName) {
158263
158381
  ts.Debug.assert(actionName === refactorName, "Unexpected action name");
158264
158382
  var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host;
158265
158383
  var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
@@ -158769,10 +158887,10 @@ var ts;
158769
158887
  };
158770
158888
  refactor.registerRefactor(refactorName, {
158771
158889
  kinds: [convertStringAction.kind],
158772
- getEditsForAction: getEditsForAction,
158773
- getAvailableActions: getAvailableActions
158890
+ getEditsForAction: getRefactorEditsToConvertToTemplateString,
158891
+ getAvailableActions: getRefactorActionsToConvertToTemplateString
158774
158892
  });
158775
- function getAvailableActions(context) {
158893
+ function getRefactorActionsToConvertToTemplateString(context) {
158776
158894
  var file = context.file, startPosition = context.startPosition;
158777
158895
  var node = getNodeOrParentOfParentheses(file, startPosition);
158778
158896
  var maybeBinary = getParentBinaryExpression(node);
@@ -158798,7 +158916,7 @@ var ts;
158798
158916
  }
158799
158917
  return node;
158800
158918
  }
158801
- function getEditsForAction(context, actionName) {
158919
+ function getRefactorEditsToConvertToTemplateString(context, actionName) {
158802
158920
  var file = context.file, startPosition = context.startPosition;
158803
158921
  var node = getNodeOrParentOfParentheses(file, startPosition);
158804
158922
  switch (actionName) {
@@ -159012,10 +159130,10 @@ var ts;
159012
159130
  toNamedFunctionAction.kind,
159013
159131
  toArrowFunctionAction.kind
159014
159132
  ],
159015
- getEditsForAction: getEditsForAction,
159016
- getAvailableActions: getAvailableActions
159133
+ getEditsForAction: getRefactorEditsToConvertFunctionExpressions,
159134
+ getAvailableActions: getRefactorActionsToConvertFunctionExpressions
159017
159135
  });
159018
- function getAvailableActions(context) {
159136
+ function getRefactorActionsToConvertFunctionExpressions(context) {
159019
159137
  var file = context.file, startPosition = context.startPosition, program = context.program, kind = context.kind;
159020
159138
  var info = getFunctionInfo(file, startPosition, program);
159021
159139
  if (!info)
@@ -159059,7 +159177,7 @@ var ts;
159059
159177
  errors : possibleActions
159060
159178
  }];
159061
159179
  }
159062
- function getEditsForAction(context, actionName) {
159180
+ function getRefactorEditsToConvertFunctionExpressions(context, actionName) {
159063
159181
  var file = context.file, startPosition = context.startPosition, program = context.program;
159064
159182
  var info = getFunctionInfo(file, startPosition, program);
159065
159183
  if (!info)
@@ -159219,10 +159337,10 @@ var ts;
159219
159337
  };
159220
159338
  refactor.registerRefactor(refactorName, {
159221
159339
  kinds: [inferReturnTypeAction.kind],
159222
- getEditsForAction: getEditsForAction,
159223
- getAvailableActions: getAvailableActions
159340
+ getEditsForAction: getRefactorEditsToInferReturnType,
159341
+ getAvailableActions: getRefactorActionsToInferReturnType
159224
159342
  });
159225
- function getEditsForAction(context) {
159343
+ function getRefactorEditsToInferReturnType(context) {
159226
159344
  var info = getInfo(context);
159227
159345
  if (info && !refactor.isRefactorErrorInfo(info)) {
159228
159346
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); });
@@ -159230,7 +159348,7 @@ var ts;
159230
159348
  }
159231
159349
  return undefined;
159232
159350
  }
159233
- function getAvailableActions(context) {
159351
+ function getRefactorActionsToInferReturnType(context) {
159234
159352
  var info = getInfo(context);
159235
159353
  if (!info)
159236
159354
  return ts.emptyArray;
@@ -163323,14 +163441,8 @@ var ts;
163323
163441
  var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
163324
163442
  possibleSearchDirs.add(projectRootPath);
163325
163443
  possibleSearchDirs.forEach(function (searchDir) {
163326
- var packageJsonPath = ts.combinePaths(searchDir, "package.json");
163327
- getTypingNamesFromJson(packageJsonPath, filesToWatch);
163328
- var bowerJsonPath = ts.combinePaths(searchDir, "bower.json");
163329
- getTypingNamesFromJson(bowerJsonPath, filesToWatch);
163330
- var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components");
163331
- getTypingNamesFromPackagesFolder(bowerComponentsPath, filesToWatch);
163332
- var nodeModulesPath = ts.combinePaths(searchDir, "node_modules");
163333
- getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch);
163444
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
163445
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
163334
163446
  });
163335
163447
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
163336
163448
  getTypingNamesFromSourceFileNames(fileNames);
@@ -163379,16 +163491,100 @@ var ts;
163379
163491
  ts.forEach(typingNames, addInferredTyping);
163380
163492
  }
163381
163493
  /**
163382
- * Get the typing info from common package manager json files like package.json or bower.json
163494
+ * Adds inferred typings from manifest/module pairs (think package.json + node_modules)
163495
+ *
163496
+ * @param projectRootPath is the path to the directory where to look for package.json, bower.json and other typing information
163497
+ * @param manifestName is the name of the manifest (package.json or bower.json)
163498
+ * @param modulesDirName is the directory name for modules (node_modules or bower_components). Should be lowercase!
163499
+ * @param filesToWatch are the files to watch for changes. We will push things into this array.
163383
163500
  */
163384
- function getTypingNamesFromJson(jsonPath, filesToWatch) {
163385
- if (!host.fileExists(jsonPath)) {
163501
+ function getTypingNames(projectRootPath, manifestName, modulesDirName, filesToWatch) {
163502
+ // First, we check the manifests themselves. They're not
163503
+ // _required_, but they allow us to do some filtering when dealing
163504
+ // with big flat dep directories.
163505
+ var manifestPath = ts.combinePaths(projectRootPath, manifestName);
163506
+ var manifest;
163507
+ var manifestTypingNames;
163508
+ if (host.fileExists(manifestPath)) {
163509
+ filesToWatch.push(manifestPath);
163510
+ manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config;
163511
+ manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys);
163512
+ addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies");
163513
+ }
163514
+ // Now we scan the directories for typing information in
163515
+ // already-installed dependencies (if present). Note that this
163516
+ // step happens regardless of whether a manifest was present,
163517
+ // which is certainly a valid configuration, if an unusual one.
163518
+ var packagesFolderPath = ts.combinePaths(projectRootPath, modulesDirName);
163519
+ filesToWatch.push(packagesFolderPath);
163520
+ if (!host.directoryExists(packagesFolderPath)) {
163386
163521
  return;
163387
163522
  }
163388
- filesToWatch.push(jsonPath);
163389
- var jsonConfig = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }).config;
163390
- var jsonTypingNames = ts.flatMap([jsonConfig.dependencies, jsonConfig.devDependencies, jsonConfig.optionalDependencies, jsonConfig.peerDependencies], ts.getOwnKeys);
163391
- addInferredTypings(jsonTypingNames, "Typing names in '" + jsonPath + "' dependencies");
163523
+ // There's two cases we have to take into account here:
163524
+ // 1. If manifest is undefined, then we're not using a manifest.
163525
+ // That means that we should scan _all_ dependencies at the top
163526
+ // level of the modulesDir.
163527
+ // 2. If manifest is defined, then we can do some special
163528
+ // filtering to reduce the amount of scanning we need to do.
163529
+ //
163530
+ // Previous versions of this algorithm checked for a `_requiredBy`
163531
+ // field in the package.json, but that field is only present in
163532
+ // `npm@>=3 <7`.
163533
+ // Package names that do **not** provide their own typings, so
163534
+ // we'll look them up.
163535
+ var packageNames = [];
163536
+ var dependencyManifestNames = manifestTypingNames
163537
+ // This is #1 described above.
163538
+ ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); })
163539
+ // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json`
163540
+ : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
163541
+ .filter(function (manifestPath) {
163542
+ if (ts.getBaseFileName(manifestPath) !== manifestName) {
163543
+ return false;
163544
+ }
163545
+ // It's ok to treat
163546
+ // `node_modules/@foo/bar/package.json` as a manifest,
163547
+ // but not `node_modules/jquery/nested/package.json`.
163548
+ // We only assume depth 3 is ok for formally scoped
163549
+ // packages. So that needs this dance here.
163550
+ var pathComponents = ts.getPathComponents(ts.normalizePath(manifestPath));
163551
+ var isScoped = pathComponents[pathComponents.length - 3][0] === "@";
163552
+ return isScoped && pathComponents[pathComponents.length - 4].toLowerCase() === modulesDirName || // `node_modules/@foo/bar`
163553
+ !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo`
163554
+ });
163555
+ if (log)
163556
+ log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames));
163557
+ // Once we have the names of things to look up, we iterate over
163558
+ // and either collect their included typings, or add them to the
163559
+ // list of typings we need to look up separately.
163560
+ for (var _i = 0, dependencyManifestNames_1 = dependencyManifestNames; _i < dependencyManifestNames_1.length; _i++) {
163561
+ var manifestPath_1 = dependencyManifestNames_1[_i];
163562
+ var normalizedFileName = ts.normalizePath(manifestPath_1);
163563
+ var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
163564
+ var manifest_1 = result_1.config;
163565
+ // If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
163566
+ // to download d.ts files from DefinitelyTyped
163567
+ if (!manifest_1.name) {
163568
+ continue;
163569
+ }
163570
+ var ownTypes = manifest_1.types || manifest_1.typings;
163571
+ if (ownTypes) {
163572
+ var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
163573
+ if (host.fileExists(absolutePath)) {
163574
+ if (log)
163575
+ log(" Package '" + manifest_1.name + "' provides its own types.");
163576
+ inferredTypings.set(manifest_1.name, absolutePath);
163577
+ }
163578
+ else {
163579
+ if (log)
163580
+ log(" Package '" + manifest_1.name + "' provides its own types but they are missing.");
163581
+ }
163582
+ }
163583
+ else {
163584
+ packageNames.push(manifest_1.name);
163585
+ }
163586
+ }
163587
+ addInferredTypings(packageNames, " Found package names");
163392
163588
  }
163393
163589
  /**
163394
163590
  * Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
@@ -163414,55 +163610,6 @@ var ts;
163414
163610
  addInferredTyping("react");
163415
163611
  }
163416
163612
  }
163417
- /**
163418
- * Infer typing names from packages folder (ex: node_module, bower_components)
163419
- * @param packagesFolderPath is the path to the packages folder
163420
- */
163421
- function getTypingNamesFromPackagesFolder(packagesFolderPath, filesToWatch) {
163422
- filesToWatch.push(packagesFolderPath);
163423
- // Todo: add support for ModuleResolutionHost too
163424
- if (!host.directoryExists(packagesFolderPath)) {
163425
- return;
163426
- }
163427
- // depth of 2, so we access `node_modules/foo` but not `node_modules/foo/bar`
163428
- var fileNames = host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
163429
- if (log)
163430
- log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(fileNames));
163431
- var packageNames = [];
163432
- for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
163433
- var fileName = fileNames_1[_i];
163434
- var normalizedFileName = ts.normalizePath(fileName);
163435
- var baseFileName = ts.getBaseFileName(normalizedFileName);
163436
- if (baseFileName !== "package.json" && baseFileName !== "bower.json") {
163437
- continue;
163438
- }
163439
- var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
163440
- var packageJson = result_1.config;
163441
- // npm 3's package.json contains a "_requiredBy" field
163442
- // we should include all the top level module names for npm 2, and only module names whose
163443
- // "_requiredBy" field starts with "#" or equals "/" for npm 3.
163444
- if (baseFileName === "package.json" && packageJson._requiredBy &&
163445
- ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
163446
- continue;
163447
- }
163448
- // If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
163449
- // to download d.ts files from DefinitelyTyped
163450
- if (!packageJson.name) {
163451
- continue;
163452
- }
163453
- var ownTypes = packageJson.types || packageJson.typings;
163454
- if (ownTypes) {
163455
- var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
163456
- if (log)
163457
- log(" Package '" + packageJson.name + "' provides its own types.");
163458
- inferredTypings.set(packageJson.name, absolutePath);
163459
- }
163460
- else {
163461
- packageNames.push(packageJson.name);
163462
- }
163463
- }
163464
- addInferredTypings(packageNames, " Found package names");
163465
- }
163466
163613
  }
163467
163614
  JsTyping.discoverTypings = discoverTypings;
163468
163615
  var NameValidationResult;
@@ -166301,30 +166448,43 @@ var ts;
166301
166448
  (_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
166302
166449
  }
166303
166450
  if (dependencyNames) {
166304
- var resolutions = ts.mapDefined(ts.arrayFrom(dependencyNames.keys()), function (name) {
166305
- var types = ts.resolveTypeReferenceDirective(name, rootFileName, compilerOptions, moduleResolutionHost);
166306
- if (types.resolvedTypeReferenceDirective) {
166307
- return types.resolvedTypeReferenceDirective;
166308
- }
166309
- if (compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
166310
- return ts.tryResolveJSModule(name, hostProject.currentDirectory, moduleResolutionHost);
166311
- }
166312
- });
166451
+ var dependenciesAdded = 0;
166313
166452
  var symlinkCache = hostProject.getSymlinkCache();
166314
- for (var _c = 0, resolutions_1 = resolutions; _c < resolutions_1.length; _c++) {
166315
- var resolution = resolutions_1[_c];
166316
- if (!resolution.resolvedFileName)
166453
+ for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
166454
+ var name = _d[_c];
166455
+ // Avoid creating a large project that would significantly slow down time to editor interactivity
166456
+ if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
166457
+ hostProject.log("Auto-import provider attempted to add more than " + this.maxDependencies + " dependencies.");
166458
+ return ts.emptyArray;
166459
+ }
166460
+ // 1. Try to load from the implementation package. For many dependencies, the
166461
+ // package.json will exist, but the package will not contain any typings,
166462
+ // so `entrypoints` will be undefined. In that case, or if the dependency
166463
+ // is missing altogether, we will move on to trying the @types package (2).
166464
+ var packageJson = ts.resolvePackageNameToPackageJson(name, hostProject.currentDirectory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache());
166465
+ if (packageJson) {
166466
+ var entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache);
166467
+ if (entrypoints) {
166468
+ rootNames = ts.concatenate(rootNames, entrypoints);
166469
+ dependenciesAdded += entrypoints.length ? 1 : 0;
166470
+ continue;
166471
+ }
166472
+ }
166473
+ // 2. Try to load from the @types package.
166474
+ var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, hostProject.currentDirectory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache());
166475
+ if (typesPackageJson) {
166476
+ var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache);
166477
+ rootNames = ts.concatenate(rootNames, entrypoints);
166478
+ dependenciesAdded += (entrypoints === null || entrypoints === void 0 ? void 0 : entrypoints.length) ? 1 : 0;
166317
166479
  continue;
166318
- var resolvedFileName = resolution.resolvedFileName, originalPath = resolution.originalPath;
166319
- if (originalPath) {
166320
- symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
166321
166480
  }
166322
- if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) {
166323
- rootNames = ts.append(rootNames, resolvedFileName);
166324
- // Avoid creating a large project that would significantly slow down time to editor interactivity
166325
- if (dependencySelection === 2 /* Auto */ && rootNames.length > this.maxDependencies) {
166326
- return ts.emptyArray;
166327
- }
166481
+ // 3. If the @types package did not exist and the user has settings that
166482
+ // allow processing JS from node_modules, go back to the implementation
166483
+ // package and load the JS.
166484
+ if (packageJson && compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
166485
+ var entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache, /*allowJs*/ true);
166486
+ rootNames = ts.concatenate(rootNames, entrypoints);
166487
+ dependenciesAdded += (entrypoints === null || entrypoints === void 0 ? void 0 : entrypoints.length) ? 1 : 0;
166328
166488
  }
166329
166489
  }
166330
166490
  }
@@ -166334,6 +166494,26 @@ var ts;
166334
166494
  (dependencyNames || (dependencyNames = new ts.Set())).add(dependency);
166335
166495
  }
166336
166496
  }
166497
+ function getRootNamesFromPackageJson(packageJson, program, symlinkCache, resolveJs) {
166498
+ var _a;
166499
+ var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache(), resolveJs);
166500
+ if (entrypoints) {
166501
+ var real_1 = (_a = moduleResolutionHost.realpath) === null || _a === void 0 ? void 0 : _a.call(moduleResolutionHost, packageJson.packageDirectory);
166502
+ var isSymlink_1 = real_1 && real_1 !== packageJson.packageDirectory;
166503
+ if (isSymlink_1) {
166504
+ symlinkCache.setSymlinkedDirectory(packageJson.packageDirectory, {
166505
+ real: real_1,
166506
+ realPath: hostProject.toPath(real_1),
166507
+ });
166508
+ }
166509
+ return ts.mapDefined(entrypoints, function (entrypoint) {
166510
+ var resolvedFileName = isSymlink_1 ? entrypoint.replace(packageJson.packageDirectory, real_1) : entrypoint;
166511
+ if (!program.getSourceFile(resolvedFileName) && !(isSymlink_1 && program.getSourceFile(entrypoint))) {
166512
+ return resolvedFileName;
166513
+ }
166514
+ });
166515
+ }
166516
+ }
166337
166517
  };
166338
166518
  /*@internal*/
166339
166519
  AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) {